Stars are several million miles away from the Earth, so far that these large heavenly bodies appear as tiny dots from here. When we watch these from our planet they tend to twinkle and this is because we view them via the thick layers of tumultuous air in the atmosphere.
Since the light of the stars pierces through several layers of our planet’s atmosphere, every single stream of this light is refracted numerous times and splits in different directions. This random spread of light results in the winking of star. The star seems to move slightly and its brightness changes a bit and to our eyes it appears as twinkling. It has been observed that the stars that are closer to the horizon tend to twinkle comparatively more than those that are overhead. This happens because the light of the stars that are located near the horizon has to travel through more amount of air as compared to the light of the stars that are overhead and it is thus subject to greater refraction.
While stars twinkle at night when viewed from Earth, they do not appear this way when seen from the outer space. You shall see them shine steadily from there as there is no atmosphere to cause turbulence in the steady streaming of their light.