Why does the temperature of the sun cool off from the core to the
surface and then get so hot again in the atmosphere?
The first part is pretty simple. The sun's furnace is near the center.
That's because the gravitational pressure there is so high that thermonuclear
burning takes place. The further one gets from the center then the cooler the
solar material. The second part is more complicated. There's a lot of funny stu ff that occurs on
the surface that involves very strong magnetic fields and a lot of stirring.
The result is that occasional hot spots flare up and shoot "hot" material
outward from the sun.