The atmosphere becomes less dense as altitude increases because there is less weight on the air molecules, making them less compressed. The air at lower altitudes is denser because it is pressed down by the weight of all the air molecules above. Also, the further away air molecules are from the Earth, the less weight they have because of a lower gravitational pull.
At higher altitudes, fewer molecules are present in the air, according to Altitude.org. There are fewer oxygen molecules, which makes breathing more difficult. In fact, planes fly at such a high altitude that they need to be artificially pressurized so that passengers can breathe.
Atmosphere density depends not only on altitude but on temperature and weather as well. Warm air is less dense than cool air because when heated, the atoms in air molecules become more active and take up more space. Weather ushers in high or low pressure systems that also affect the density of the air. Water vapor decreases the density of air because water molecules take up space that nitrogen and oxygen would normally occupy, and the weight of water in its gaseous state is lighter than that of the equivalent nitrogen and oxygen atoms.