This study investigates the influence of magnesium (Mg) doping on ZnO thin films prepared through spin coating to enhance their efficiency and stability in perovskite solar cells (PSCs). The incorporation of Mg significantly enhanced charge transport, reduced recombination losses, and enhanced overall device stability. The structural, optical, morphological, and electrical properties were investigated using UV-Vis spectroscopy, field-emission scanning electron microscopy (FESEM), energy-dispersive X-ray spectroscopy (EDX), and Hall Effect measurement. SCAPS-1D simulation software was utilized to study the performance of the solar cell under different Mg doping concentrations in order to determine the optimum conditions for the maximum power conversion efficiency (PCE). Simulation findings exhibit adequate utility regarding power conversion efficiency (PCE) gain of around 21.89% with optimized Mg doping, which is equivalent to undoped ZnO film performance. While the PEC performance of the doped ZnO is comparable to that of its undoped counterpart, this study reveals notable improvements in optical tunability, charge transport properties, and, in simulations, reduced defect-related trap densities that suggest more favorable band alignment. Simulation results show enhanced PCE of 21.89% under optimal Mg doping compared to undoped ZnO, along with substantial band alignment adjustments, optical tunability, and charge transport. While efficiency enhancements are marginal, these developments signify future possibilities toward enhanced device longevity. Results displayed are SCAPS-1D simulation-based, and experimental validation is required to determine device-level stability and performance. It should be noted that any additional device fabrication or physical characterization are not possible at this time; hence, conclusions are limited to the simulation results and film-level characterizations given in this document.