

Those are already arguments for why NASA and space programs shouldn’t exist in the first place.
I remember watching something about the space race, and there was a clip of public opinion during the time of the first mission to the moon, where a man complained that the money should’ve been used to improve the lives of poor Americans instead.
Regardless, for the scenario in The Martian, if money is already being spent and going to continue being spent on space missions in the future, I think you can rationalize it as using money for another or next space mission. They would still gain knowledge from what they had to do to pull off that rescue, so it’s not a complete waste of funds for a mission either.
On the morality point, I’d argue that we should spend the money to rescue any person if we have the money/means, and it can feasibly happen without excessive risk to other lives, otherwise we’re assigning monetary value to human lives. That includes both people in imminent danger, requiring expensive emergency services, and people suffering slower, persistent risks like hunger that require sustained support.
In that scenario, I agree the pragmatic choice is to save the majority.
But many situations tend to be complex and aren’t as clear as a trolley problem, so I want to avoid falling into the trap of seeing a false dilemma when there’s possibly more than two options.