With the advancement of vehicle electrification and intelligence, distributed drive electric trucks have emerged as the preferred choice for heavy-duty electric trucks. However, the control of yaw stability remains a significant issue. To tackle this concern, this study introduces a layered control strategy for yaw moment. Specifically, the upper layer utilizes a yaw moment controller based on linear quadratic regulator (LQR) to compute the additional yaw moment required. Additionally, in order to enhance the performance of the yaw moment controller, the weight matrix in LQR is optimized using a hybrid Genetic Algorithm and Particle Swarm Optimization algorithm (GA-PSO). The lower layer consists of a torque distribution layer, which establishes an objective function for minimizing tire utilization rate. Quadratic Programming algorithm is then employed to compute the optimal torque distribution value, thereby improving the vehicle’s stability. Subsequently, the stability control effects of the vehicle are simulated and compared on the Matlab/Simulink Trucksim joint simulation platform using four control strategies: the proposed control strategy, SMC, LQR, and without yaw moment control. These simulations are conducted under two working conditions: serpentine and double lane change. The results demonstrate that the proposed approach reduces the average yaw rate by 14.4%, 19.6%, and 42.15% while optimizing the average sideslip angle by 25.9%, 24.8%, and 52.3% in comparison to the other three control strategies. Consequently, the proposed control strategy significantly enhances the driving stability of the vehicle. Furthermore, the optimized allocation method reduces the average tire utilization rate by 42.6% in contrast to the average allocation method, thereby improving the stability control margin of the vehicle. These findings successfully validate the efficiency of the yaw stability control strategy presented in this article.