Here's how it works:
1. Light from a distant star travels through the Earth's atmosphere. This atmosphere is not a uniform, smooth medium.
2. The air is constantly moving and changing in density. This means that different parts of the air have different refractive indices (how much they bend light).
3. Light from the star gets bent in different directions as it passes through these pockets of air. This bending is called refraction.
4. The amount of bending changes constantly, leading to a rapid variation in the direction of the light reaching our eyes.
5. This rapid change in direction causes the light to appear to flicker or twinkle.
Think of it like looking through a rippling pool of water. The light from a source beneath the water appears distorted and flickering due to the movement of the water.
Important Note: Planets, which are much closer to us than stars, don't twinkle as much. This is because they appear as larger discs of light, so the atmospheric turbulence affects different parts of the disc in different ways, averaging out the twinkling effect.