Compared to the planets, the stars are very far from Earth. Neptune, the furthest discovered planet from Earth, orbits some 2,697,000,000 miles from the Earth. The stars are much further away than this. The nearest star to our sun, Proxima Centauri, is located 4.2 light years away. The light year is a measure of distance. Light travels 5,880,000,000,000 miles in a year. There are countless stars, some of them trillions of light years away.
Because they are so far away, only a tiny fraction of any star's light ever reaches the Earth. As space is mostly empty, the light travels all those light years unimpeded. But the light is eventually impeded before it reaches the eye. Were an observer standing on the moon, or stationed somewhere in space, the stars would shine as steadily as the planets do. To most observers, though, they do appear to twinkle. This occurs because before it can be observed, the bit of light that reaches us from the stars must first pass through the Earth's atmosphere.
An atmosphere is a layer of gases surrounding a star or planet. Some moons have atmospheres as well. The Earth's atmosphere is primarily composed of nitrogen and oxygen throughout, but it still has several distinct layers. These layers differ from one another in areas such as temperature, air pressure and wind speed. Starlight must pass through the Earth's atmosphere to be observable from the Earth's surface. As it does so, the light is refracted.
When light enters a medium that will force it to adjust its speed, this is called refraction. A beam of starlight passes easily through space, but bends when it hits the outer layer of the Earth's atmosphere. The Earth's atmosphere has several layers. Each has a separate density and temperature. This means that the beam of light bends several times before reaching Earth's surface. Because of these refractions, the stars appear to move and twinkle. The more atmosphere the already weak light must pass through, the more pronounced the effect.