Here's how it works:
* Earth's gravitational pull: The Earth's mass creates a gravitational field that pulls everything towards its center, including the gases in the atmosphere.
* Atmospheric pressure: The weight of the air above creates atmospheric pressure, which pushes down on the air below. This pressure is what keeps the gases from escaping into space.
Think of it like this: Imagine a balloon filled with air. The air inside the balloon is held in place by the balloon's skin, which is analogous to the Earth's gravitational field.
It's important to note that while gravity holds the atmosphere near the Earth, it's not a perfect seal. Some gases, like hydrogen and helium, are light enough to escape Earth's gravity over time. This process is called atmospheric escape.