Aiming at the problem that the absolute positioning accuracy of the robot end-effector decreases due to geometric errors, such as those from manufacturing and assembly, and nongeometric errors, such as joint flexibility and gear clearance in industry, a hierarchical compensation method of robot positioning error is proposed. First, an improved crayfish optimization algorithm (ICOA) and a multiobjective ICOA (MOICOA) are proposed. Aiming at the model condition number and position distribution, the identification points are optimized by a multiobjective approach. Moreover, the geometric error of the robot is compensated with the minimum positioning error of the robot end-effector as the goal. Second, based on data-driven, the Gaussian process regression (GPR) model is established, and its hyperparameter is optimized by ICOA so as to regress and compensate the nongeometric errors of the robot. Finally, the experiment of hierarchical compensation of positioning error is conducted using a universal six-degree-of-freedom (6-DOF) serial robot. The experimental results show that the maximum error, mean absolute error, and root-mean-square error (RMSE) of the position error are reduced by 95.43%, 92.39%, and 95.01%, respectively, after geometric error and nongeometric error compensation, which verifies the correctness and effectiveness of this method. The research results of this article provide a theoretical basis for the robot's high-precision operation.