Stars twinkle when they are seen from the Earth's surface because they are being viewed through thick layers of turbulent (moving) air in the Earth's atmosphere.
The light from the stars travels through the many layers of the Earth's atmosphere, and the light of the star is bent or refracted many times and in random directions because it encounters a change in density - like a pocket of cold air or hot air along with change in temperature.( The density of air decreases with increasing altitude).This random refraction results in the star twinkling out.
Now, density, temperature and pressure work together to change the conditions of the air. When heat is added, air temperature and pressure both increase. And when the density of air changes, the pressure (and sometimes the temperature) does as well.
This change in the atmospheric density is due to earth's gravity that causes the downward force known as "weight."
Regards.