There are poor people in every country. Can you name a country where every single citizen has housing, enough to eat, and good health? According to you all countries must stop all spending on space programs, since the money could be used for housing, food or health.
The reality is that the amount of money spent on science is relatively miniscule, and no country can hope to advance without investing anything in science.