As I said above, this is a problem of the economic system itself. First you need to study this issue. Today, we cannot abandon enterprises that emit harmful substances. Also, completely ecological enterprises do not exist, since in the process of manufacturing something there will always be something that will need to be thrown away (in any aggregate state). In addition, all laws that "regulate" the issue of harmful emissions are nothing, since there are no sanctions for those who do not adhere to them. All countries strive for the economic well-being of their citizens, as well as primacy in the political arena of the world, therefore no one will reduce their economic power due to climate change.
One way or another, I agree with you that the money needs to be redistributed for the needs of the population, but in this world this is impossible. And at the expense of the space industry, I can confidently say that it needs to be developed even more, we see that times are not calm and we need to develop technologies as soon as possible that can deliver people to at least Mars and terraform it for favorable conditions. At times, it seems that the technologies are stuck and nothing has really changed since the first launches.
That amount of money that is about to be spent on some space projects can be donated to some needs of those people who starve or have health problems, or such stuff like ecology and climate change.
I don`t say that space projects shouldn`t be invested, but we should not forget the issues we have on Earth.