Of course the sun will render the Earth uninhabitable long before it burns out, but we're still talking about a billion years or so, and I argued we simply can't make plans today for an event hundreds of millions of years in the future. Argue space exploration is a moral imperative because of the knowledge it brings, but don't tell me it's necessary to avoid extinction.
The knowledge it brings has no moral value unless there are people to have the knowledge, so continued existence comes along for the ride by extension.