In order to improve the driving performance of four-wheel drive electric vehicles and realize precise control of their speed, a Chaotic Random Grey Wolf Optimization-based PID in-wheel motor control algorithm is proposed in this paper. Based on an analysis of the structural principles of electric vehicles, mathematical and simulation models for the whole vehicle are established. In order to improve the control performance of the hub motor, the traditional Grey Wolf Optimization algorithm is improved. In particular, an enhanced population initialization strategy integrating sine and cosine random distribution factors into a Kent chaotic map is proposed, the weight factor of the algorithm is improved using a sine-based non-linear decreasing strategy, and the population position is improved using the random proportional movement strategy. These strategies effectively enhance the global optimization ability, convergence speed, and optimization accuracy of the traditional Grey Wolf Optimization algorithm. On this basis, the CR-GWO-PID control algorithm is established. Then, the software and hardware of an in-wheel motor controller are designed and an in-wheel motor bench test system is built. The simulation and bench test results demonstrate the significantly improved response speed and control accuracy of the proposed in-wheel motor control system.