The vacuum of space does not suck away Earth's atmosphere because Earth's gravity is strong enough to hold onto it. The force of gravity between two objects is directly proportional to the product of their masses and inversely proportional to the square of the distance between them. Earth has a much greater mass than the atmosphere, so the gravitational force between Earth and the atmosphere is much greater than the gravitational force between the atmosphere and space. This means that Earth's gravity is strong enough to hold onto the atmosphere, even though space is a vacuum.
In addition, the atmosphere is not a uniform mass of gas. It is made up of layers of gases with different densities. The denser gases, such as oxygen and nitrogen, are located closer to Earth's surface, while the less dense gases, such as helium and hydrogen, are located higher up. This stratification of the atmosphere helps to prevent it from being sucked away by the vacuum of space.