John Graham, an astronomer at the Carnegie Institution of Washington, explains.

The length of a star’s life depends on how fast it uses up its nuclear fuel. Our sun, in many ways an average sort of star, has been around for nearly five billion years and has enough fuel to keep going for another five billion years. Almost all stars shine as a result of the nuclear fusion of hydrogen into helium.

This takes place within their hot, dense cores where temperatures are as high as 20 million degrees. The rate of energy generation for a star is very sensitive to both temperature and the gravitational compression from its outer layers.

These parameters are higher for heavier stars, and the rate of energy generation–and in turn the observed luminosity–goes roughly as the cube of the stellar mass.

Heavier stars thus burn their fuel much faster than less massive ones do and are disproportionately brighter. Some will exhaust their available hydrogen within a few million years. On the other hand, the least massive stars…

Full story here.