Answer:
Primarily because the atmospheric pressure is decreasing (the higher you go, the less atmosphere is above you), and temperature goes down as pressure goes down. It's also true that the sun heats the earth's surface and generally not the atmosphere, but this has little to do with the temperature dropping as you go up.