The Earth will not last forever no matter what the cause of it's eventual demise. Large Asteroid, large comet, the Sun exploding, etc. That is in spite of how well or not we manage our behaviour while occupying it.
Life has all but ceased and then restarted several times but eventually the Earth will no longer sustain life in any form. The universe is a very dangerous place. Human life will live on only if we leave the Earth eventually and seed in more places. Redundancy of sustainable habitats is the only option.
But don't be too depressed if humanity doesn't survive, there will no doubt be life forms surviving elsewhere in the universe, it's a large place.
Lefty