Most people are familiar with the fact that generally speaking, air temperature tends to decrease with increasing elevation. When a trip to the mountains is planned, many people will bring along some extra warm clothing just in case the temperature is too cold. But what accounts for this temperature drop? Asked to give specifics, the majority of people would be left speechless. But in reality, the mechanisms behind this phenomena are really easy to grasp.
In order to put things into proper perspective, you must visualize the air around you as being made up of billions and billions of tiny air molecules. These air molecules are, of course, invisible to the naked eye, but they are everywhere! Now, a second piece to add to the puzzle is gravity. The gravitational pull of the earth is strongest near the earth's surface. So, all of those billions and billions of air molecules that are floating around you are being held close to the ground by gravity. Now, here is where it gets a little more advanced. The heat that you feel in the air on any given day - the air temperature - is the result of "indirect" sunlight. The sun rises in the sky and the sun's rays beat down on the earth. However, the air is not heated directly from the sun's rays; instead, the sun's rays heat the earth, and the earth heats the air! This process is what's known as "radiational heating," the heat radiates from the earth's surface to the air.
So, you know that the air around you is heated from the ground up. Since gravity is keeping the majority of the atmosphere close to the ground by way of its gravitational pull, the majority of air molecules are going to be closer to the ground. Each air molecule has the ability to retain heat; the more air molecules you have in a given measurement of air, the greater the ability to store heat. So, as you move further and further up into the atmosphere, you reach areas of the atmosphere that have fewer and fewer air molecules - the air is less-dense - because gravity is keeping the majority of air molecules closer to the ground. So, at higher altitudes, the air is less-able to store heat. In a nutshell, that is the whole process. It all boils down to the following: gravity, density of the air, and the radiational heating of the air indirectly from the sun!