Gravity keeps the gases from going out to space. Gravity weakens as you get farther away from surface, so the number of molecules decreases with altitude. Density decreases with altitude. Even though we can't feel the constant bombardment of air, the push of tiny molecules, we can detect rapid changes. Ears popping - air collisions outside the ear drum lessen.
Ear popping, occurs as the molecules on the inside and outside equalize.
Pressure is force per unit area. The pressure at any level in the atmosphere may be measured in terms of the total weight of the air above any point - atmospheric pressure. Pressure always decreases with altitude. Blow up a balloon - the number of molecules, and the speed, colliding against the sides determines the air pressure inside. You have to do work to blow up the balloon.