Yes, absolutely spending the money is a great investment. According to a Huffington Post article (https://www.huffpost.com/entry/misconceptions-nasa_b_3561205) studies have estimated that each dollar spent in the NASA budget results in a $7-$14 return of the investment. NASA's budget is only about 0.5% of the federal budget so why save a nickel today to lose multiple dollars of returned investment which mostly goes to the U.S. Treasury to help fund other programs such as social security.
Eliminating NASA completely wouldn't help those billions of people because that problem isn't scientific. If it was a problem of science it would already be solved because the technology to feed, clothe and house everyone on Earth already exists. On one hand the problem is cultural because there are groups of people who voluntarily reject medical treatment to their own detriment and are often suspicious of medical professionals who offer help. It's also a political problem because there are political leaders who restrict access to medical services to their citizens because citizens who are sick or malnourished lack the spirit to revolt and are more concerned with trying to live one more day.
The one thing that has decreased in price and is cheaper now than it was 50 years ago is information and one of the most efficient ways to get out of poverty and stay out of poverty is to become educated. NASA's research contributions that have lead up to the smartphone have helped to allowed a cheap and very powerful computational device to be made available to the poor. According to https://www.businessinsider.com/world-population-mobile-devices-2017-9 two-thirds of the world is connected by mobile devices and by 2020 alsmost 75% will be connected.
That's just one example. NASA research has lead to new materials, medicines, optics, ect. that has affected almost everybody on Earth to one degree or another.
RE: Should we invest in space exploration while millions of people die of hunger?