People said outside earth is a vacuum. But the air does not get sucked from the Earth's surface. Some said it is due to gravity and some said the speed of air molecules are not high enough to escape. We know vacuum will suck air like your vacuum cleaner and it has nothing to do with gravity. If outer space is really a vacuum, what prevents air escape the earth?
Vacuum doesn't suck air. In a vacuum it is the other air which pushes it into the empty space. Air like any other gas will expand to fill the volume.
So you would expect the atmosphere to spread out to fill the rest of the universe - and without gravity holding it onto the Earth, it would do.
Edit: Yes some air is continually lost. The molecules in the atmosphere are moving at a range of speeds, some of the very fastest ones will be moving fast enough to have enough energy to overcome gravity and escape. This is especially true for the lightest elements, eg. Helium, which move fast and feel the effect of gravity least.
"Some said X, some said Y" - in your case, X and Y are the same. Gravity is what gives you the escape velocity - without gravity, all velocities would be escape velocities. The atmosphere does leave, as a certain proportion of the air molecules gets sufficient speed all the time. However, the average velocity of air molecules is much lower than the escape velocity, so it's a relatively rare event - we lose about 3kg of atmosphere every second. That sounds like a lot, but there's a lot of air in the atmosphere, so it would last about a billion years if the loss rate remained constant.
In reality, the atmosphere lasted much longer than that, and will last quite a while, because it's actually being replenished over time. The most stable part of our atmosphere is the nitrogen, because it isn't lost easily (it has lots of mass and the molecule is very stable); the most loss we get is from hydrogen, which is continually replenished mostly from water vapour. Erosion and volcanic activity release huge amounts of carbon dioxide, which is processed by photosynthetic life to produce oxygen, and mostly captured and returned back for another round as various limestones and silicates.
Right now, the atmospheric loss is pretty close to an equilibrium - the amount of new atmosphere being created is pretty close to the atmospheric loss. The equilibrium is pretty stable - you don't get a positive feedback loop where more atmospheric loss leads to even more atmospheric loss, it's actually the opposite.
Finally, there is no sucking. You can't pull on a volume of air - what actually happens is that the ambient air has a higher pressure, so it moves into the low-pressure volume. There is no real force, just statistics - for a volume of randomly moving particles ("ideal gas"), it's more probable for a molecule to move from the high pressure area to the low pressure area than vice versa. Over time, this roughly equalizes the pressure in the two volumes - that's the point where moving from A to B is just as likely as moving from B to A.
But even then, you see that the air would just spread to fill the whole universe equally, no sucking involved. That's where gravity comes in - the movement of individual air molecules is no longer entirely random, since they are pulled towards the center of the planet. If an air molecule ends up on a trajectory away from the Earth, it would get turned around until it points back to Earth (just like a ball comes back down to Earth when you throw it up). And that's where escape velocity comes in - that's the velocity where Earth's pull isn't strong enough to turn the object around. The molecule is still continually accelerated back to Earth, but the force of gravity (and thus the acceleration) drops off faster than the molecule's velocity - the molecule "escaped" the gravity well.
Try to refrain from using the word 'suck' here as it makes no sense. Air will always move from a region of high pressure to a region of low pressure. Just like everything else in nature; it tries to equilibrate itself.
People said outside earth is a vacuum
Well they are all wrong, there is no such thing as a perfect vacuum. Maybe this is a bit pedantic but I think it's best to say that outside the earth the pressure is very, very low (or "almost a vacuum").
But the air does not get sucked from the earths surface.
Yes it does, but only an absolutely tiny amount, very fast moving molecules are able to overcome the gravitational force acting on them from the earth and will escape into space. Researchers have discovered that oxygen is (very) slowly draining out of Earth's atmosphere.
Here are some useful images from the link I provided:
Some said it is due to gravity and some said the speed of air molecules are not high enough to escape.
Those that said it was due to gravity are correct. The others are wrong for reasons that I mentioned above.
Comments below this answer have identified a good point in that the last quotation both arguments are the same. Now I acknowledge that these statements are very similar and could be interpreted as the same thing. But I still stand by what I wrote originally.
If the second part of the quote had said "the speed of all of the air molecules are not high enough to escape". Then I would agree with the comments and revise my answer.
The atmosphere diffuses smoothly into outer space, there being no strict boundary. The example you gave with a vacuum cleaner is not the same as a vacuum in outer space. Consider the earth and its atmoshere as a system $S$. The vacuum cleaner does not remove air from $S$ but merely redistributes it. The gravitational field of the earth binds the molecules within a certain average distance of its surface. To remove particles from this surface, work has to be done to supply the molecules enough kinetic energy to escape the gravitational pull of the earth. Mere vaccum is not a source of energy. On the other hand, cosmic rays inonise the outer layers of our atmosphere, and often allows some gaseous ions to diffuse further than the estimated atmospheric height.
There is one more aspect to this calculation which I haven't seen yet, so I'm going to post it here: the recovery of interstellar matter by the action of the earth sweeping through space and collecting material as it goes. One figure for the density of interstellar matter is 1 atom (hydrogen) per cm^3. Multiply this by the orbital speed of the earth (30 km/sec) and the cross-sectional area of the planet, I get a mass of very close to the same 3 kg/sec which Luann cited in his very thorough answer as the quantity of atmospheric gases normally escaping by simple diffusion into the vaccuum. So much of what we lose may be recovered simply by sweeping it back from "empty" space.
Strictly speaking, vacuum cleaners don't suck, they blow. In other words, the fan pushes air downstream through and ultimately out of the device. The displaced air results in a region of lower pressure upstream of the fan (lower than ambient). This creates an imbalance of forces on the air upstream of the fan; this imbalance causes the air to move through the inlet into the machine. For what it's worth, the low pressure region in an operating vacuum cleaner is far from what could reasonably be called a vacuum (maybe one or two PSI below ambient).
In order for anything to leave Earth and never return, be it a spacecraft, a particle of dust, or a molecule, it must be travelling at or above escape velocity - about 11km/sec at Earth's surface, just a tiny bit less at the Karman line (the altitude deemed to be the edge of space). Any slower, and the object will follow an orbital trajectory around or back down to Earth.
Gas is a collection of molecules moving around in space, colliding with objects or other molecules. Individual molecules in a sample of gas will have different speeds, according to a statistical distribution; the average speed (kinetic energy, actually) is described by the parameter we call temperature.
Happens all the time
It is possible for a molecule of gas to acquire, say from a collision, escape velocity, and if that molecule happened to be high enough up in the atmosphere to not run into anything else, can leave Earth permanently. It happens all the time, just not at a high enough rate to be significant. Unless the molecules happen to be very light like hydrogen or helium. It is because they are light that they can be more easily accelerated to escape velocity under conditions where other molecules like nitrogen and oxygen can't.
It does. The solar wind consisting of charged energetic particles will bump into oxygen/nitrogen molecules and accelerate them in some cases to escape velocity. Fortunately the earth's magnetic field diverts most of these charged particles away from the thick part of our atmosphere. In the absence of solar wind, nitrogen and oxygen have insufficient energy at normal temperatures to reach escape velocity. However hydrogen and helium escape our atmosphere quickly and easily. New helium constantly enters the atmosphere as a by-product of radioactivity (alpha radiation from radioactivity is a helium nucleus which only needs to pick up a readily available electron to form helium gas).
There is a balance between the gravity force and escaping velocity. When the escaping velocity is very high, the gravity force cannot hold the particle and we will loss that particle. The gravity depends on the planet's mass but the escaping velocity depends on temperature. If there is gas on Venus (used to have?), the temperature is such high that gas has high escaping velocity and it will keep losing gas until none. For planet that is far away from sun (Mars?), the gravity force may win the battle that the air can be very close to the ground surface. If there were living animals, they should crawl on the floor because the temperature is not enough to get the air moving higher.
You miss the gravity pull. It keeps the whole atmospheric ensemble bounded to the earth, since it acts on every molecule. It is interesting to note that above the altitude at which molecules do not interact within themselves in distances greater than what it is called "atmospheric scale height", there exists a theoretical estimation of neutral particles escaping the atmosphere by computing the proportion of a given species with velocities greater than escape velocity. This distribution is known as "Jeans Escape".
Some rocky bodies from our solar system are believed to have lost most of their atmosphere due to the atmosphere escape as in Mars, which has a milder gravitational pull. Nevertheless the theory about this is highly dependent on interactions with the planet internal structure and it is not so simple.