Actually, it's the force of gravity that creates the density of the air. As one descends from the upper air, we are piling more and more air onto the lower altitudes. So near the surface there's a lot of air in that column of air over head.
In other words, there is simply more air overhead when we're near the surface of the planet than if we were, say, up above the highest mountains. And because there is more air at the bottom near the surface there is more air pushed into a small space than air pushed into the same volume up higher.
And more of something crammed into the same volume means more density. It's the force of gravity that crams that more air into the small volume. It's the force of gravity that creates the higher density near the surface of the planet. Not the other way around that you suggest.
Some suggest there are two models for what creates the force of gravity. I think there is but the one: gravity is created by the compacting of space.time by the presence of mass.energy.
In other words, when you plunk a bit of mass, the Earth for example, into the middle of otherwise empty space, space itself compacts around that mass. And in that compacting, space forms what is known as a potential energy well. And like any well, if something falls into that well that something falls and accelerates toward the bottom of that well.
And there you are. Falling and accelerating towards the mass, e.g., the Earth, are the characteristics of the gravity force. When a body is dropped into a potential energy well it falls and accelerates towards the bottom of that well.
So the answer to your question is...no, gravity cannot be explained by the density of air. (In fact, the Moon has gravity but no air whatsoever.) But gravity forces can be explained as a potential energy well caused when mass.energy compacts space.time around it. [See source.]
The general theory of relativity.