What makes you think protecting our environment and space exploration are mutually exclusive?
As other's have pointed out already, technologies developed for the space program are already hugely in daily use and an integral part of modern life, and that will keep happening. There's medical research being done that's a potential game changer currently.
But, off the top of my head (and I'm far from an expert) - water recycling and reclamation techs, alternative fuels, better and more efficient battery technology, smaller, safer nuclear tech, harsh environment crops, high-usage, hard wearing fabrics...
A viable Mars shot will need all of those. We definitely do, to begin colonisation. We'll also need terra-forming tech to rejuvenate soil and reseed the atmosphere if we're going to stay there.
If the tech can be used on Mars, it can potentially be used on Earth. If we can plant and grow on the Moon or Mars, we can plant and grow in the dustbowls of Africa and the deserts. If we can build an atmosphere there, we can repair ours. A big issue in our energy networks is efficient transmission and storage - cleaner, safer nuclear addresses this, as do long-storage batteries that don't use horribly polluting and incredibly rare elements. If we're forced to develop a battery that can store and yield for months for a Mars shot, that's tech that can come home into the EV industry. Biggest problem converting all cars to EV - the batteries are heavy, polluting, flammable and don't hold great charges. Solve that, and the world can convert. There's a huge chunk of the oil demand addressed.
They aren't exclusive goals.
To get to Mars, we have to go back to the Moon, and it's really not as easy as 'just go then.' This is how we do that.
Could we develop all those things without the space program - maybe. Would we - maybe not. If there's no end-goal and no money to fund the research, it won't get done.
The biggest periods of tech improvement are wars - because there's motivation for development. I'd rather we went to the Moon, and to Mars.
Too, the whole of human history has been 'what's next?' This is what's next. We've been looking up at the stars since we were Apes. Get a child interested in Space and you get them interested in math and science, tech and engineering. They're curious and they want to learn. Just inspiring that is a worthy goal all on its own for me.
You're calling it 'boys toys', but an express goal of Artemis is to put the first woman on the moon. Until this mission, no woman has left Earth-orbit - the Apollo astronauts were all men. That changes now. In a time were there's a concerted attack on women's rights and freedoms and equality, that's huge. That's an international generation of girls looking up - like the boys did with Apollo - and saying 'okay, maybe this stuff is for me?'
But yeah, let's not try for any of that because your petrol got expensive.