Our atmosphere has millions of gas molecules and atoms. Each molecule has its own velocity. mostly our atmosphere filled with Nitrogen(78%), Oxygen(21%) and rest of the amount occupied by the various gases like hydrogen, carbon dioxide, sulfur dioxide and etc. velocity of these gas molecules is much lesser than the escape velocity of the earth(11.2 Km/s).
Only objects can escape from the gravity of Earth when the exceeds the escape velocity. Similarly all planets and even stars have its own escape velocity.(example: Mars(5.03 km/s); Saturn(35.5 km/s); Jupiter(59.5 km/s)).
The velocity of gas molecules:
Essential gas molecules or atoms for animals and planets are Nitrogen, Oxygen and Hydrogen. the velocity of these molecules are lesser than the escape velocity of Earth so, they can’t escape from the Earth’s gravitational attraction, but in the case of Moon it’s quite different. These gas molecules velocity is quite larger than the escape velocity of the Moon(2.32 Km/s). So, the Moon can’t able to hold these molecules.