system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5:Why is it that the higher the altitude, the lower the temperature?

Shouldn't it get hotter since we're closer to the sun?
gpt
The sun is too far away to make a few tens of kilometers matter.

The difference is pressure. Pressure and temperature are related. Temperature is about the average amount of movement in the molecules of gas in a given volume. As there are less molecules in gas at a lower pressure, there is less movement. 

Another point is that air that is rising experiences a drop in pressure. It has to expand as it does so, and that expansion is movement, and movement needs energy. That energy comes from the heat energy of the air, cooling it. This is TERRAOperative's explanation in different words.

The third is Juanfro's - the Sun's energy travels through the transparent air, and heats the Earth's surface. The hot surface of the earth heats the air close to it, and that makes the air nearer to the surface hotter.