This paper proposes a new optimization method by immune algorithm to reduce the impact of clearance joint and wear on the dynamics of mechanisms. Firstly, the dynamic model of crank-slider mechanism is built by Lagrange principle, and the wear phenomenon of clearance joint is characterized by Archard model. Then, the motion function reliability model of mechanism is presented by Stress-Strength interference (SSI) theory. Secondly, the optimization model of mechanism is derived and the surrogate model of the maximum contact force of clearance joint is indicated by response surface method (RSM), the immune algorithm is used to find the optimal solution of the surrogate model. Finally, the impact of wear and optimization on dynamic behavior, nonlinear dynamics, and motion function reliability of mechanism is investigated. The results show that wear clearance joint seriously affects the performance of mechanism. After optimization, the dynamic behavior and nonlinear dynamics of mechanism are improved, and the motion function reliability of mechanism is increased. This paper raises foundation for predicting the performance of mechanisms considering wear clearance joint, and provides theoretical guidance for optimization design and fault diagnosis of mechanisms.