Research on infrared detectors has been widely reported in the literature. For infrared detectors, PbS, InGaAs, PbSe, InSb, and HgxCd1-xTe materials are the most widely used and have been explored for photodetection applications. However, these are toxic and harmful substances which are not conducive to the sustainable development of infrared detectors and are not eco-friendly. Mg2Si is a green, healthy, and sustainable semiconductor material that has the potential to replace these toxic and damaging photoelectric materials, making photoelectric detectors (PDs) green, healthy, and sustainable. In this work, we report on the results of our simulation studies on the PN junction Mg2Si/Si heterojunction PD. A model structure of Mg2Si/Si heterojunction PD has been built. The effects of Mg2Si and Si layer thickness on the optical and electrical performance of Mg2Si/Si heterojunction PD are discussed. For the purpose of this analysis, we consider electrical performance parameters such as I–V curve, external quantum efficiency (EQE), responsivity, noise equivalent power (NEP), detectivity, on-off ratio, response time, and recovery time. The simulation results show that the Mg2Si/Si heterojunction PD shows optimum performance when the thickness of Si and Mg2Si layers are 300 nm and 280 nm, respectively. For the optimized structure, the reverse breakdown voltage was found to be −23.61 V, the forward conduction voltage was 0.51 V, the dark current was 5.58 × 10−13 A, and the EQE was 88.98%. The responsivity was found to be 0.437 A/W, the NEP was 6.38 × 10−12 WHz1/2, and the detectivity was 1.567 × 1011 Jones. With the on-off ratio of 1566, the response time was found to be 0.76 ns and the recovery time was 5.75 ns. The EQE and responsivity peak wavelength of PD show a redshift as the thickness of Mg2Si increases. The Mg2Si heterojunction PD can effectively detect infrared light in the wavelength range of 400 to 1400 nm. The simulation results can be utilized to drive the development of green Mg2Si/Si heterojunction PD in the future.