Ever heard of gravity? The gas isn't normally compressed. So it wants to decompress all the time. The gas is continuously compressed. So continuously heated up. The energy put into the system via gravitational pull must go somewhere. In the end you get a balance between cooling off/heating up and you reach a stable end temperature
I suppose I was a bit blunt in my previous post... this time I've taken more time to write an answer.
The gas is in equilibrium ... gravity wants to compress it, but the pressure of the gas acts as a counter.
This equilibrium exists at a certain value of temperature, pressure and density.
All of this doesn't prevent the gas to lose energy to its surroundings. It will cool down and grow denser. And it will still be in equilibrium at the earth's surface.
Of course you are right that gravity matters, because that influences the pressure at which the gas must achieve an equilibrium.
Gravity itself does not create energy, because the gravity does not actually move the gas. It tries to, but it doesnt. Doing "work" means that you've to move something. But nothing is being moved and there is no energy put into the atmosphere. That's because all forces are in equilibrium - the gravity and the pressure counteract each other, meaning there is no net energy change in the gas.
You are confusing this with the act of rapidly compressing a gas. If you do that, you are exerting a great force and you are adding lots of energy into the gas.
But once you stop movement, the gas will cool down to room temperature and find a new equilibrium at that temperature/pressure/density.
http://en.wikipedia.org/wiki/Ideal_gas_law
For an ideal gas: Pressure = constant * Density * Temperature.
Let's see a very simple example at the earth's surface:
force1 = Pressure * Area.
force2 = gravity = 9.8 * (Mass of a column of air with area A).
In equilibrium, the two forces cancel each other: force1 = force2. At the earth's surface, the pressure must be high enough to support the weight of all the air above it in a column of gas with area A.
Pressure * Area = 9.8 * Mass = constant * Density * Temperature * Area
If we keep the area constant, then you can consider the Mass a constant because we won't add or remove gas from the atmosphere. This means that Density * Temperature = some constant for the atmosphere.
So as temperature drops, density will increase. The gas will still be in an equilibrium state.
(I hope I didn't make some silly mistake here...)
Perhaps I should also mention the law of physics that says, "energy = work done"
And work means: applied force over some distance.
In short: Force * Distance = Energy.
It's easy to make the mistake that time is also a factor, but it isn't really. Forces may change over time, then it'll be part of the equation but only because the force changes, for example velocity * time = distance travelled. What matters is the distance.
I'm writing this, because you're under the impression that the longer gravity is present, the more energy it will create... well it doesn't. Gravity will only add energy to an object, if it's allowed to move. For example a stone that drops will gain energy. But a stone that's kept in the air by an opposing force, will not gain any energy.
How does this compare to the atmosphere... well... the atmosphere itself has energy (or temperature) and the atmosphere itselfs exerts this force to keep a balance. If the atmosphere could keep its temperature forever, then gravity can pull all it wants, it will never ever change anything... because the two forces would oppose each other into infinity.
In practice, the atmosphere continuously radiates energy out into space. Without the constant addition of energy from the sun, the atmosphere would slowly cool down. There's nothing that would prevent this from happening. Gravity doesn't stop radiation...
So in short:
Gravity controls the pressure / density.
The sun controls the temperature / energy.
And if you would like to be nitpicky, then you could argue for this: when the atmosphere cools down, it will shrink under the influence of gravity and it should heat up. But I'm not sure if even that is the case ... after all the shrinking is the result of loss of heat by radiation and occurs at a constant pressure ... gravity has nothing to do with that.
Another thing about "work" that should be mentioned is, that if the path over which a force is applied is "closed, then no net work is done: no energy is gained or lost. As an example, take one air molecule and let it bounce around in a cage. First it will go up, it will lose kinetic energy because it goes in the opposite direction of gravity. Next it will bounce down, and will gain kinetic energy because it goes in the direction of gravity. Net result? No change.
Now imagine a whole atmosphere of molecules bouncing around in the earth's gravity field. The field doesn't change and the molecules don't go anywhere, they're aimlessly bounding around, some gaining energy, some losing energy, but there is no net change in energy.
So basically you got the gravity force which doesn't change, and you got the air molecules that will bounce around forever, because they're really really good at bouncing. There is nothing gained...
There's only some loss because of heat-radtiation by the molecules.