For starters, gravity counteracts the pressure of the air. It is therefore responsible for the fact that the atmosphere as a whole is not rapidly distancing itself from the earth but is essentially stationary (again, as a whole).
To see where gravity is important just consider the behaviour of the atmosphere if there were no gravity. Well, that actually doesn't work well -- withoug gravity there would be no atmosphere at all.
Vertical air movements are mostly a result of bouyancy forces, with denser parcels of air descending and less dense parcels of air ascending. Bouyancy forces are caused by gravity, specifically the difference in gravitational forces depending on density.
Horizontal air movements are due to pressure differences. It is gravity that creates such pressure differences (indeed, all atmospheric pressure) with areas having less air above them (generally due to lower density) having lower pressure than areas with more air above them (generally due to higher density).