Presently, impurity-compensated silicon (Si) has no clear potential applications due to high resistance and few carriers. Thus, it has received little attention from researchers. In this study, we find that impurity compensation can make localized state energy levels form in Si bandgap, which can improve the light absorption of Si in the near infrared region. In this work, in order to comprehensively and deeply understand the photoelectric properties of impurity-compensated Si, the localized state energy levels composed of P<sup>+</sup>/B<sup>–</sup> ions are constructed in Si bandgap through the co-doping of phosphorus (P) and boron (B), thereby forming impurity-compensated Si. The first-principles based on a density functional theory framework is used to study the photoelectric properties of the impurity-compensated Si (n/p-Sic) such as the density of states (DOS), dielectric function and refractive index. The DOS study reveals the following results: after the n- and p-Si with the same concentration of P and B (12.5%) are fully compensated for by impurities, the Fermi energy levels of their compensated counterparts are at the valley bottom formed by the two adjacent DOS peaks, and the DOS is not zero at the valley bottom. In the study of dielectric function and refractive index, it is found that when the doping ratio is <i>C</i><sub>B</sub>/<i>C</i><sub>P0</sub> = 0.25, n-Sic has the largest dielectric function and refractive index in the low energy region. In addition, comparing intrinsic Si with its doped counterparts in the real part (Re) of their dielectric constant, the following regularity is found: in the high energy region of <i>E</i> > 4 eV, the Re values of the intrinsic Si, n/p-Si and p-Sic are negative. In the low energy region of 0.64 eV< <i>E</i> < 1.50 eV, the Re value of n-Sic is negative for the doping ratio of <i>C</i><sub>B</sub>/<i>C</i><sub>P0</sub> = 0.25. The above comparison indicates that the n-Sic with <i>C</i><sub>B</sub>/<i>C</i><sub>P0</sub> = 0.25 can achieve good metallicity in the low energy region, indicating that the electrons in valence band are easily excited by low-energy long-wavelength light. Theoretical studies show that the good photoelectric properties of n-Sic with <i>C</i><sub>B</sub>/<i>C</i><sub>P0</sub> = 0.25 may be related to Si dangling bonds and localized state energy levels in Si bandgap. The Si dangling bonds are caused by the impurity compensation of B dopant for n-Si, leading part of Si-Si bonds to change into Si-B bonds. This study provides theoretical guidance for the application of impurity-compensated Si in the field of photodetectors such as CMOS image sensors and infrared photodetectors.