The Sun is basically a hot ball of gas, powered by nuclear reactions at its core and eventually radiating that power out into space at its outer surface. The temperature at the core is millions of degrees, so that the “light” produced there is mainly x-rays. But this light must travel through an enormous amount of matter to get to the surface of the Sun, being scattered, absorbed, and re-emitted so many times that an astounding 100,000 years and possibly ten times more are needed for the energy generated in the core to get to the surface.
This energy is spread over a larger and larger area as it moves outward. The average temperature of the radiation drops as it moves out, but in such a way that the total – that is, the local intensity multiplied by the area of the larger and larger surface – remains a constant. By the time the energy reaches the visible surface of the Sun, the temperature has dropped to about 5800 K (10,000°F). This puts the radiation emitted into the visible part of the spectrum – our eyes almost certainly having adapted to the available wavelengths, thereby making them the “visible” part.