Also an extinction level event happening on this planet is a certainty, so it's actually an infinite order of magnitude better to figure out how to live in space than to only focus on saving the earth.
But again, a truly intelligent species would do both.
The dinosaurs are a good example of a group of species that weren't far-sighted enough to invest in a serious space exploration and settlement program.
If we knew that a cretaceous extinction event will happen five, fifty, or five hundred years from now, it'll be orders of magnitude easier for civilization to survive on Earth, then it will be for it to survive in space.
If dinosaurs had opposable thumbs, and technology, they would have been better off bunkering down. No matter how uninhabitable some freak civilization-ending event would leave the Earth, it would still be more habitable then anywhere else in the Solar system.
It's also quite possible to do multiple things at once when you have a civilization with many members. So as I said before, a truly intelligent species would not put all its eggs in one basket. They'd work on figuring out how to colonize space at the same time as figuring out how to deflect asteroids and also handle asteroid impacts if they did happen.
When you have limited resources, you deal with a problem that's going to affect half the population of the planet in the next 20 years, as opposed to dealing with a much harder problem that might affect the entire population of the planet in a once-per-fifty-million-years lottery.
We are currently putting all of our eggs in one basket, because climate change will kill modern civilization much faster then we can move the entirety of modern civilization into a <even less hospitable off-planet environment>.
An 'intelligent' person would do all of those things - because, after all, nuclear war can start any moment, our roads and sidewalks are dangerous places, and you never know where your next meal is going to come from.
Worrying about planet-ending disasters, and establishing civilization in space is much like doing any of the things I've listed. It's not intelligent - it's a non-cost-efficient response to incredibly unlikely occurrences. Especially when there are incredibly likely occurrences, that we'd be much better off preparing for, instead.
In short, planet-ending disasters are not the only reason to develop these capabilities, and it's shortsighted and stupid to continue to destroy our environment here without taking advantage of all the resources and opportunities outside our gravity well.
If we cared about this sort of thing, we would be doing it now, as opposed to sitting on our hands, waiting for magical space unicorns to be invented.
The ROI on the former is many orders of magnitude better.