Stars "get" their energy by converting some of the energy locked into the elements they are made of into motion and electromagnetic radiation. This is accomplished through fusion, where smaller and less massive elements like hydrogen and helium get smooshed together strongly enough to form a new, more massive element like barium or lithium.
In general, elements do not WANT to get smooshed together. The electrons and protons they are made of repel other electrons and protons, because they have the same charge. In the case of stars, there is so much matter that the force of gravity is enough to force them together. So, as smaller elements get fused by gravity, the Star uses up what is essentially its fuel.
The basic rule of thumb here is that the larger and more massive the star is, the faster it manages to fuse all the small elements it contains, and therefore the more quickly it runs out of fuel. Larger stars "die" faster, because their large gravitational force lets them use up fuel faster.
The largest stars can survive for only millions of years in some cases. Meantime, smaller stars like our own can last multiple billions of years.
Keep in mind, I am leaving out a ton of info here. But the rule of thumb works. Smaller stars live longer.