As starlight travels towards an observer on Earth it has to pass through the Earth’s atmosphere where the light is distorted by layers of air of differing temperature and thickness. Because these layers of air are also in constant and turbulent motion, from the observer’s point of view the stars appear to flicker. Seen with naked eye they seem to twinkle, while through a telescope they appear blurred. Basically the effect is the same as when the air above a hot road surface in summer seems to shimmer. When stars are observed from space or from the Moon, which has no atmosphere, they do not twinkle. However, there are some stars whose brightness really does vary, although these variations occur very slowly, over periods of days, weeks or even months.
Air shimmers above a hot road because different layers of air have different temperatures-this is the same effect that makes stars twinkle.