Many issues concerning the origin of high-temperature superconductivity (HTS) are still under debate. For example, how the magnetic order varies with doping and its relationship with the superconducting temperature (T-c); and why T-c always peaks near the quantum critical point. In this paper, taking hole-doped La2CuO4 as a classical example, we employ the first-principles band structure and total energy calculations with Monte Carlo simulations to explore how the symmetry-breaking magnetic ground state evolves with hole doping and the origin of a dome-shaped superconductivity region in the phase diagram. We demonstrate that the local antiferromagnetic order and doping play key roles in determining the electron-phonon coupling, thus T-c. Initially, the La2CuO4 possesses a checkerboard local antiferromagnetic ground state. As the hole doping increases, T-c increases with the enhanced electron-phonon coupling strength. But as the doping increases further, the strength of the antiferromagnetic interaction weakens and spin fluctuation increases. At the critical doping level, a magnetic phase transition occurs that reduces the local antiferromagnetism-assisted electron-phonon coupling, thus diminishing the T-c. The superconductivity disappears in the heavily overdoped region when the ferromagnetic order dominates. These observations could account for why cuprates have a dome-shaped superconductivity region in the phase diagram. Our study, thus, contributes to a fundamental understanding of the correlation between doping, local magnetic order, and superconductivity of HTS.