When you look into the night sky, you may notice that the stars flicker or twinkle; their light does not appear to be constant. This is not caused by inherent properties of the stars themselves. Instead, the Earth's atmosphere bends the light from stars as it travels to your eyes. This causes the sensation of twinkling.
As light passes through any medium, it bends. This process is called refraction. Changes in the medium can change the degree to which the light is refracted. The turbulence of the Earth's atmosphere is caused by shifting layers of air at different temperatures and densities. Consequently, the light that passes through the atmosphere will be refracted by regions with different densities. The light that you see from stars gets shuffled through the Earth's atmosphere, and you perceive this as a twinkle.
Variation in Twinkling
The amount of refraction that starlight experiences also depends on the angle at which you observe the star. If a star is directly overhead, its light will intersect the Earth's atmosphere at an angle close to perpendicular, minimizing refraction in general. Consequently, it will travel through a minimal amount of the Earth's atmosphere, thereby minimizing the refraction caused by atmospheric disturbances. On the other hand, if the star is near the horizon, its light must travel through a larger amount of the atmosphere. The effects of atmospheric refraction will therefore be stronger, and the star will likely twinkle more.
Planets Vs. Stars
Planets do not twinkle in the same way that stars do. This is because they are closer to the Earth. The stars are so far away that they appear like points of light in the sky. The planets are close enough that they appear as very small disks. While the light from the planets is also refracted through the atmosphere, the net result of the turbulent refractions is spread across the visible disk of the planet, so you don't see the planet twinkle in the same way as you do a star. Still, you may occasionally see a planet twinkle, especially when it is close to the horizon.
Avoiding the Twinkle of Stars
To avoid the twinkle of stars, astronomers can try to move their telescopes such that starlight passes through a minimal amount of the Earth's atmosphere. This is one of the reasons why many observatories are built on mountaintops. Furthermore, astronomers have placed some telescopes in space, which gives them glimpses of starlight undisturbed by the atmosphere. Astronomers can also use telescopes equipped with a technology called adaptive optics. Adaptive optics detects the atmospheric disturbance and corrects the telescope image with a deformable mirror to provide a clearer picture of the star.