Their mass, for the most part. The more massive the star, the stronger is its gravitational field and the hotter the core of the star can become. The hotter the core, the faster it burns its hydrogen into heavier elements and the faster its nuclear fires burn. It's that simple. For stars 50 times the mass of the Sun, they last about 10 million years. For stars 1/100 the mass of the Sun, they can last up to a trillion years!