Stars (except Sun) appear as tiny dots in the sky. As their light travels through the many layers of the Earth's atmosphere, the light of the star is bent (refracted) many times and in random directions. This random refraction results in the star winking out . It looks as though the star moves a bit, and our eye interprets this as twinkling.
Stars would not appear to twinkle if we viewed them from outer space.