The thermosphere is the hottest layer in the atmosphere because

It is the closest to the sun
Air molecules generate heat
Greenhouse gases absorb cold
The ozone layer reflects the suns heat