The sun's atmosphere acts as a thick filter through which the high energy gamma rays, generated in the solar core, must pass. These gamma rays are dangerous to humans. As they move through the sun's atmosphere they are converted into photons of harmless visible light. How very fortunate for us!
Here's how it works....
The gamma rays emitted during the proton-proton chain, collide with the electrons in the dense solar core, producing slightly lower energy photons at each encounter. Initially the gamma rays cannot move more than a fraction of a centimeter before colliding with electrons in the core.
Because they spend so much time bumping into electrons and changing the direction in which they are moving, it takes about 170 thousand years for photons to get from the sun's core to the solar surface. This is about the length of time that has elapsed between the appearance of cavemen on the Earth and now.
Once outside the sun, they zip through space to arrive at the Earth only 8 minutes later.