The scientific name for the twinkling of stars is stellar scintillation (or astronomical scintillation). Stars twinkle when we see them from the Earth's surface because we are viewing them through thick layers of turbulent (moving) air in the Earth's atmosphere
Stars (except for the Sun) appear as tiny dots in the sky; as their light travels through the many layers of the Earth's atmosphere, the light of the star is bent (refracted) many times and in random directions (light is bent when it hits a change in density - like a pocket of cold air or hot air). This random refraction results in the star winking out (it looks as though the star moves a bit, and our eye interprets this as twinkling).
Regard