I'd argue we need to do both, but that getting off-planet is actually the bigger priority: even if we run our planets poorly, we'll be safe from complete extinction, which gives us time to optimize in the long run.
Taking care of what we have right now is the bigger priority because failing that we never will get off the planet anyway.
Getting off the planet requires a larger degree of international cooperation and funding than stewarding our own planet does. If we can't manage the one we certainly won't be able to manage the other. Also, it is something that we actually can do, if we set our minds to it. Whether or not we can actually get off the planet with meaningful numbers of people to a place that is no longer tied to the earth in some critical way remains to be seen.
Translation: "We need to clean up our act in this cave before we try building grass huts. Otherwise we'll just make the same mistakes out there that we're making in here."
We actually could try to build grass huts when we were still living in caves. But we currently can't 'try to get off the planet', not even for very small numbers of people. The ISS is as good as it gets at the moment and that's solidly tied to our economies and our ability to supply it.
And even that might not last long. Space is - sadly - currently not a priority.