The atmosphere derives heat from the sun, which emits radioactive waves towards it. This heat then spreads throughout the atmosphere via radiation, convection and conduction.
There are three ways the sun heats the atmosphere.
The sun constantly emits radiation, which is stronger on some days than others. This radiation moves in straight lines, and as the Earth is in their path of trajectory they enter the Earth's atmosphere. It is thanks to the Earth's axis that the radiation distributes in a way that allows most of the planet to remain habitable. Most of the radiation that enters the Earth's atmosphere is absorbed, while the remainder provides heat.
A small amount of heat moves through the Earth's atmosphere via conduction. Conduction occurs when energy transfers in one format to a material in the same or another format. For example, when someone burns themselves on a fire, it is energy in the form of heat conducting from the source. Air is the main conductor in the Earth's atmosphere, and it is not very effective. It only distributes heat very close to the surface.
It is thanks to convection that heat moves from the small areas of conduction, upwards into the atmosphere. Conduction is possible when liquids and gases are present. When energy transfers to liquids and gases they move freely upwards, spreading heat around.