Around each star there is a narrow range of distances where a planet can orbit and liquid water will exist on its surface. Too close to the star and the high temperature will cause the water to boil into steam. Whilst too far away and the temperature will be so low that any water will freeze.
We call this the 'habitable zone' (sometimes called 'the Goldilocks zone') because it is the area around a star that is not too hot and not too cold to sustain the conditions required for life to exist. Liquid water is vital for life to exist on a planet.
To sustain life on its surface a planet must have an atmosphere. The atmostphere on Mars is very thin because Mars is too small to have a magnetic field. A planet's magnetic field protects its atmosphere from being stripped away by the constant bombardment of cosmic particles from the star.
Life on Earth is carbon-based. This is because carbon allows large structures to form that are the basis for all life on Earth. Nitrogen in the air is a fundamental part of our DNA and amino acids. Oxygen allows for respiration. Hydrogen and oxygen also form water, which is the foundation of life on Earth.
The conditions most likely to support life on exoplanets are:
However, all of these simply describe Earth. It could be possible for life elsewhere in the universe to be as versatile as life on Earth. Planets that we consider uninhabitable could harbour very differnt forms of life.