The movement of air masses has to do with density and temperature. Air masses that are more dense will sink toward the ground while air masses that are less dense will rise into the atmosphere. Cold air has less kinetic energy than warm air, so the air molecules are packed closer together and the cold air is more dense than warm air. So warm air will tend to rise while cold air will sink toward the ground. As warm air rises into the atmosphere, however, it will cool since the atmosphere thins out and retains less heat the further away you get from the surface of the Earth. So the warm air mass will eventually cool and move back down toward the surface. This means that there is a constant flow of air in the atmosphere, thus giving rise to the wind and weather patterns we see on Earth.