This study introduces and compares two optimization techniques, the basic Artificial Bee Colony (ABC) and the enhanced Artificial Bee Colony with multi-elite guidance (MGABC), for determining optimal gains of a Proportional-Integral-Derivative (PID) controller in a 3 degrees of freedom (DOF) rigid link manipulator (RLM) system. The objective function used in the optimization process is a novel function that is based on the well-known Lyapunov stability functions. This function is evaluated against established error-based objective functions commonly used in control systems. The convergence curves of the optimization process demonstrate that the MGABC algorithm outperforms the basic ABC algorithm by effectively exploring the search space and avoiding local optima. The evaluation of the controller's performance in trajectory tracking reveals the superiority of the Lyapunov-based objective function (LBF), with significant improvements over other objective functions such as IAE, ISE, ITAE, MAE and MRSE. The optimized system demonstrates robustness to diverse disturbance conditions and uncertainty in the mass of the payload, while also exhibiting adaptability to joints flexibility without inducing any vibrations in the movement of the end-effector. The proposed techniques and objective function offer promising avenues for the optimization of PID controllers in various robotic applications.