Stellar twinkling (scintillation) is caused by Earth's atmosphere. As starlight passes through layers of air with varying temperature and density, it refracts (bends) randomly. This makes the star's apparent position and brightness fluctuate rapidly—what we perceive as twinkling.
Planets rarely twinkle because they're closer and appear as tiny disks, not point sources. Atmospheric refraction averages out across their disk.
Note: Twinkling is a challenge for ground-based astronomy; adaptive optics and space telescopes (Hubble, JWST) circumvent it.