The reason why there is more air closer to the surface is because the gravity of the Earth pulls the air down towards the ground. The air is compressed by the weight of the air above it, which makes it denser. The denser air is less likely to rise, so it stays closer to the surface.
The density of air also depends on the temperature. Warm air is less dense than cold air, so it rises. This is why hot air balloons rise. The air inside the balloon is heated, which makes it less dense than the surrounding air. This difference in density causes the balloon to rise.