The actual stars don’t twinkle. The twinkling we see is due to the earths atmosphere. In fact the stars are glowing balls with never ending glow, placed trillions of kilometres away.
Light from these far away stars first enters the earths atmosphere, and bends while passing through different layers of the earths atmosphere and we get to see a point of light twinkle . Due to this refraction(bending of light), the stars appear to be twinkling. The technical term for this is “STELLAR SCINTILLATION”.
This twinkling of stars helps astronomers to differentiate planets from stars.
As we know, our own sun is a star, then why it doesn’t twinkle?
You guessed it, our sun isn’t so far away from our planet earth. For this reason the refraction is not noticeable.
Here’s a fun fact, when we look at a star, we actually look at the image of the star. In real time, the star may not be there at that particular position, because the light takes comparatively more time to reach our eye from the star.