What determines a star's lifespan?
A star's lifespan is determined by its mass.
The longest lived stars are red dwarf stars which can shine for trillions of years. These stars have a low mass less than 0.5 solar masses.
Our sun is a yellow dwarf star and has a lifetime of about 10 billion years.
Really massive giant stars on the other hand have a lifetime of only a few million years.
The reason why the lifetime of a star is related to its mass is because of the way stars produce energy. Main sequence stars are fusing hydrogen into helium. There are two main types of fusion reaction.
Smaller stars generate most of their energy using the proton-proton chain reaction. When to protons get close enough together in the star's core the strong force binds them into a Diproton. Most of the Diprotons disintegrate due to electrostatic repulsion. Sometimes one of the protons in a Diproton disintegrates by the weak force into a neutron, a positron and an electron neutrino to form Deuterium. Deuterium then fuses with a proton to form Helium-3. Two Helium-3 react to form Helium-4 and two protons.
Larger stars generate most of their energy using the Carbon-Nitrogen-Oxygen (CNO) cycle where Carbon acts as a catalyst for fusing Hydrogen into Helium.
Unlike the proton-proton chain, the CNO cycle is very sensitive to temperature. Larger stars have hotter cores. The hotter the core the more energy is generated by the CNO cycle.
Although high mass stars have more Hydrogen to start with, their hotter cores fuse Hydrogen at a much faster rate resulting in a shorter lifetime.