|Stars twinkle for the same reason that the air shimmies above a radiator or a fire or hot pavement; because of warm air rising in the atmosphere.
Heat can move in one of three ways. The first isconductance. In conductance, the heat passes through something solid, such as wood or metal. This process is pretty slow.
Another way heat moves isradiation. In radiation, the heat passes directly through space in the form of photons, tiny packets of energy travelling at the speed of light. Radiation is the way that the sun's warmth reaches Earth.
Finally there'sconvection. In convection, heat warms the air. The warm air becomes less dense (and thus lighter) than the cool air around it, so it rises. Convection is the reason stars twinkle.
When air heated by convection rises, it tumbles and swirls. When light passes from the cool, dense air through the warm swirling, not-so-dense air and back again, it gets bent this way and that. That's why the air shimmies over a fire or a radiator.
As air warmed by the earth rises through the atmosphere, it breaks into bubbles of warm air. As light from the stars passes through the bubbles, it's bent back and forth. This is what makes the stars seem to twinkle.
If there weren't any atmosphere, as on the moon, the stars would shine steadily.