Droplet dynamics on a solid substrate is significantly influenced by surfactants. It remains a challenging task to model and simulate the moving contact line dynamics with soluble surfactants. In this work, we present a derivation of the phase-field moving contact line model with soluble surfactants through the first law of thermodynamics, associated thermodynamic relations and the Onsager variational principle. The derived thermodynamically consistent model consists of two Cahn–Hilliard type of equations governing the evolution of interface and surfactant concentration, the incompressible Navier–Stokes equations and the generalized Navier boundary condition for the moving contact line. With chemical potentials derived from the free energy functional, we analytically obtain certain equilibrium properties of surfactant adsorption, including equilibrium profiles for phase-field variables, the Langmuir isotherm and the equilibrium equation of state. A classical droplet spread case is used to numerically validate the moving contact line model and equilibrium properties of surfactant adsorption. The influence of surfactants on the contact line dynamics observed in our simulations is consistent with the results obtained using sharp interface models. Using the proposed model, we investigate the droplet dynamics with soluble surfactants on a chemically patterned surface. It is observed that droplets will form three typical flow states as a result of different surfactant bulk concentrations and defect strengths, specifically the coalescence mode, the non-coalescence mode and the detachment mode. In addition, a phase diagram for the three flow states is presented. Finally, we study the unbalanced Young stress acting on triple-phase contact points. The unbalanced Young stress could be a driving or resistance force, which is determined by the critical defect strength.