Great question, one that had scientists baffled for years. Problem was that they assumed it was a balance of gravity and energy released in fusion that kept a star burning however when you calculate the life span our sun should of burnt out thousands of years ago so something is not quite right. The solution came from quantum mechanics and the Pauli Exclusion Principle (PEP) which states “no two fermions can exist in the space in time”, basically spin 1/2 particles fill discreet energy levels. This means that a star is a balance of gravity and PEP that keeps it burning. The same applies for white dwarfs, neutron stars and black holes however fusion is replaced typically with other energy sources that lead to their respective appearances.