Robotic friction stir welding (RFSW), with its wide application range, ample working space, and task flexibility, has emerged as a vital development in friction stir welding (FSW) technology. However, the low stiffness of serial industrial robots can lead to end-effector deviations and vibrations during FSW tasks, adversely affecting the weld quality. This paper proposes a dynamic dual particle swarm optimization (DDPSO) algorithm through a new comprehensive stability index that considers both the stiffness and vibration stability of the robot to optimize the installation position of complex space curve weldments, thereby enhancing the robot’s stability during the FSW process. The algorithm employs two independent particle swarms for exploration and exploitation tasks and dynamically adjusts task allocation and particle numbers based on current results to fully utilize computational resources and enhance search efficiency. Compared to the standard particle swarm optimization (PSO) algorithm, the DDPSO approach demonstrated superior search capabilities and stability of optimization results. The maximum fitness value improved by 4.2%, the average value increased by 12.74%, and the concentration level of optimization results rose by 72.91% on average. The new optimization method pioneers fresh perspectives for optimizing the stability of RFSW, providing significant grounds for the process optimization and offline programming of complex spatial curve weldments.