The sun produces heat derived from energy through a variety of means, such as fusion, radiation and convection. Heat is the transfer of energy from one body to another, so the heat from the sun is the result of the energy produced in its core being transferred outward into space.
The sun produces a massive amount of energy due to the nuclear fusion reaction in its core, in which the element hydrogen is converted into helium. The temperature in the core is about 13,600,000 degrees Kelvin, and this heat is transferred into the next layer through thermal radiation. After that, the heat is carried to the surface of the sun through convection. From the surface, where the temperature is around 5,700 K, the energy from the sun travels throughout space in the form of light radiation. A portion of this light reaches Earth, and some of the energy is trapped by the atmosphere, heating Earth.
Substances on Earth are heated at the molecular level, as the light from the sun excites the atoms that make up the substance. The infrared portion of the sun's light resonates with some of the atoms in the substance, and these vibrating atoms collide with other atoms in the substance, dispersing the energy and producing heat.