When you look up at the night sky, almost every star appears to fluctuate rapidly in brightness, or blink in and out, or shift positions slightly. The little stars are twinkling, twinkling (the scientific term is scintillation or astronomical scintillation), but why?
There used to be two theories about twinkling. One held that Earth's atmosphere is the cause. To get from the star to us, the starlight travels through layers of air. As the light enters each layer, it is refracted, or bent, at an angle dependent on the temperature and density of that layer. Low frequency light is refracted at a smaller angle than higher frequency light, so different colors of light wind up traveling different paths. On top of that, all that air moves around because of wind, solar convection, etc., changing the light's already convoluted route. The result is that an earthbound observer is seeing the accumulated refractions of the light as it arrives via different paths and perceives the star quickly changing brightness, size and position.
The other theory had it that something happening out towards the edges of the Solar System, like gas clouds, caused the twinkling in much the same way Earth's atmosphere might. Objects closer to Earth, like the sun, don't twinkle because their light doesn't have to pass through the clouds like stars' light does.
All that needed to be done to test the atmosphere theory was get an observer beyond Earth's atmosphere and have them look at a star. The debate was settled when Ronnie Walter "Quincy" Cunningham, an astronaut on the Apollo 7 mission, did just that. He later published Importance of Observation That Stars Don't Twinkle Outside the Earth's Atmosphere.
If the atmosphere causes twinkling, though, why don't planets, the moon and the sun twinkle? Because they're closer than stars. Stars are far enough away that their light appears to come from a single point in the sky. With the moon, sun and some closer planets, light appears to come from a small disk in the sky and comes from multiple points. The light from each of these points is refracted just as much as the light from stars, but these points have strength in numbers and the twinkling of one point is easily masked by another, giving us a consistent, non-twinkling image.