There are many complex processes on Earth that make it suitable for life. Based on our current understanding the key ingredient is liquid water.
Water turns into ice at a temperature of 0 degrees Celsius and into water vapor at 100 degrees Celsius. So, if life needs the presence of liquid water, this means that not all planets (or moons) are able to support life.
Circumstellar habitable zone
To support liquid water and life, a planet needs to receive the necessary amounts of energy from a star. So two major factors that influence habitability are:
Distance of a planet from a star
Size of the star
Astronomers have defined the range of orbits around a star that would enable a planetary surface to support liquid water given sufficient atmospheric pressure as the circumstellar habitable zone.
Earth is within this zone and receives the necessary amounts of energy from the Sun to support liquid water and life.
How many habitable planets are there?
As many as 40 billion planets could exist in the habitable zone of their star, roughly 1 in 5 planets. So although planets orbit around many stars, they need to form at the right place to enable the conditions for life.
Earth is one such planet and this is a key reason why our planet is suitable for life.