About five billion years from now, the Sun’s usual source of nuclear energy will be depleted. It will begin to expand and cool significantly, becoming a ‘red giant’. Its outer layers will be thrown off into space. As the Sun loses mass, its gravitational pull will weaken and the planets’ orbits will widen. We know that Mercury and Venus will not be able to outrun the expanding Sun, and will be engulfed and incinerated.
Earth may just outrun the swelling red giant but its proximity, and the resulting rise in temperature, will probably destroy all life on Earth, and possibly the planet itself. However, there’s no reason that life could not survive on another planet (or moon) sufficiently far out from the Sun, as long as it lies within the Sun’s expanded ‘habitable zone’. Life could also survive on suitably hospitable planets around other red giants.