The sun is hot because of the constant nuclear fusion happening between isotopes of hydrogen atoms. That fusion creates an ENORMOUS amount of energy. The energy created from the nuclear fusion travels outward from the sun in the form of solar radiation. Too much solar radiation can be a very bad thing for a planet – just look at Mercury! – but at just the right distance (called the Goldilocks Zone) the solar radiation is strong enough to heat the planet, but not roast it. When solar radiation (actually a spectrum of different wavelengths of radiation) reaches the Earth, it mostly doesn’t actually heat the planet itself, but heats up our atmosphere, which is like a protective blanket keeping us at just the right temperature in the icy void of space. The warmth of the sun’s radiation held in the atmosphere also keeps us warmer at night, when the sun’s rays aren’t directly hitting us, which is a very, very good thing!
When we stand in the sun and feel hot, what we are actually feeling is the effect of billions of hydrogen atoms crashing together, throwing energy out across space, where it is filtered by our atmosphere (which draws off the worst of the heat) and the remaining part excites the atoms of our skin – making us nice and warm. Cool, eh?!