In outer space, stars generally do not twinkle. Rather, their light tends to be diamond-clear, with no apparent internal motion.
Terrestrial scintillation, commonly known as twinkling, can occur only when a star is viewed from within atmosphere, and that only because atmospheres are not of consistent density. Pockets of air differ in temperature from those around them. Some parts of the atmosphere may be richer in nitrogen, others in oxygen or carbon dioxide. The atmosphere itself is layered with air of different density and pressure, and those layers do not remain absolutely constant. Every time the light from a star encounters a density differential, it is refracted and distorted, to the point that the light may actually change colour. If this were all, the clear light of the star would simply be converted to a static fuzzy blur: but air is constantly moving, and so the density differences are constantly changing, typically at more than 100 times a second. This continual movement of air of irregular density is what creates a telescopic 'seeing disc' out of a star, and gives us the visual effect of a twinkling star.
The closer to the horizon, the more the star will twinkle. Light from stars closer to the horizon has to go through more air than light from stars directly overhead, so it also travels through more changes of air density. It also travels through more air that is relatively close to the surface of water and earth, where abrupt changes in temperature are most common.
The star's distance from the earth makes no difference to how well it twinkles. At astronomical distances, all stars are effectively point-source illumination. The only differences occur once the light hits the earth's atmosphere. However, because shorter wavelengths scatter more, stars toward the blue end of the spectrum will tend to twinkle a bit more than stars toward the red end of the spectrum.
The best telescopes on the surface of the earth have been built at high altitudes to minimise this atmospheric shimmer, although even these optical instruments are still within the earth's atmosphere, and so they cannot escape it entirely.
However, stars can also sometimes twinkle in outer space. This phenomenon is most often due to irregular oscillation within the star itself, or sometimes to the presence of a companion star. A star may also twinkle when viewed through a visible or invisible nebula, where the changing densities of the plasma refract the star's light and add a twinkle. In fact, the existence of some otherwise invisible nebulas has been betrayed by just such an unexpected twinkle, with spectral analysis of the starlight giving the likely composition of the hidden nebula.
It is said that planets don't twinkle. It is true that they generally don't twinkle as much as stars. Unlike stars, which are so far away that the source of light is effectively a point, planetary light is reflected from a distinct disk. This wider source of light has the effect of minimising the apparent movement of the light due to atmospheric effects: making planets fuzzy, but usually not twinkly. The major exceptions to this rule are Venus and Mercury, whose proximity to the sun is such that they can only ever appear as morning or evening stars. This close to the horizon, at the temperature-changing times of dawn and dusk, the air through which their light travels to reach us dances, and so, sometimes, their light does also.