Military spending (eg USA, Russia, China), politically motivated public works (eg Japan), propping up failing industries for political reasons (eg car industry in Australia or USA), not to mention all the money that gets wasted on consultants, starting projects and not finishing them, poorly thought out stimulus packages...
There is a huge double standard where some things undergo a stringent cost/benefit analysis and other things are not scrutinised at all. Also the upside or benefit of scientific investment can be astronomically and unpredictably high. How can you compare building more public housing to inventing the semiconductor industry?