Here's why:
* Nuclear Fusion: Stars like the Sun generate energy through nuclear fusion, specifically by fusing hydrogen atoms into helium. This process releases immense energy, providing the outward pressure that balances the inward force of gravity.
* Hydrogen Depletion: As the star continues to fuse hydrogen, the core gradually accumulates helium, which is inert in this process. This means there's less hydrogen available for fusion, and the rate of fusion decreases.
* Gravitational Collapse: With less outward pressure from fusion, the star's core begins to contract under its own gravity. This contraction increases the temperature and density of the core.
* Shell Burning: The increased temperature and pressure eventually ignite hydrogen fusion in a shell surrounding the core, where there's still enough hydrogen. This causes the star to expand and become a red giant.
* Helium Fusion: If the core reaches a high enough temperature (around 100 million degrees Celsius), helium fusion can begin, producing carbon and oxygen. This phase marks the end of the main sequence and the star's transition into a different evolutionary stage.
In essence, the star's evolution is driven by the depletion of its primary fuel source (hydrogen) and the subsequent changes in its internal structure as it attempts to maintain equilibrium. The Sun will spend approximately 10 billion years on the main sequence before becoming a red giant.