There are at least 100B stars in our galaxy. Over the last 20+ years we've gained a lot data on exoplanets. Exoplanetary systems seem to be really common. So stability, the right elements, etc no doubt all play a role but we may be talking over WWhata trillion planetary bodies (including large moons).
What's more, our understanding of where live can evolve, survive and thrive has greatly expanded in recent decades and now includes volcanic vents on the ocean floor, for example.
So yes a lot of things have to go right but we're rolling an awful lot of dice.