This is known as Wien's Displacement Law, which states that the wavelength of peak emission for a blackbody is inversely proportional to its temperature. The Sun's surface temperature is around 5,778 Kelvin, which corresponds to a peak emission around 500 nanometers.