Recent improvements in robotic arms have increased their interest in many areas such as the industry and biomedical sectors. Path planning is an essential part of the robotic arm, since most automated factories seek to move things from one place to another with obstacles providing the shortest route. This paper presents a novel optimal path planning algorithm based on the 3D cubic Bézier curve with three shape parameters and its geometric properties and hierarchical clustering. The proposed method utilizes a feature vector which is obtained from curvature, torsion, and path length of candidate curves. A hierarchical clustering is applied to determine curve pairs. Then, a multi-objective function is used to determine the best curve pair, which gives the best curve for the robotic arm. Besides forming the optimal 3D cubic Bézier path, the optimal ruled and developable path surfaces are obtained. In addition to presenting theoretical results, this work also demonstrates the proposed method on several Kinova Gen3 robotic arm cases.