On a several decades/century scale it's worthwhile to funnel at least a few percent of GDP into basic science research[1]. But, in any given quarter/year, it's almost certainly a net loss. The trick being that every few decades, you'll get nuclear power, the transistor, etc[2].
Or, as a 'local' example: non-trivial number theory had basically no benefit for centuries but humanity kept 'investing' resources into it - which a short term optimizer wouldn't. Then, cryptography came along and it suddenly 'paid' for the entire field a dozen times over.
[1]: Research is sort of like early stage VC - but with funds that pay out over 70 years instead of ~7.
[2]: I would love to write about many more examples in much more depth, but will omit for the sake of brevity. I roughly feel like the newtonian mechanics was directly responsible for the industrial revolution, relativistic physics for the nuclear age, quantum mechanics for the computer age (with similar analogues in the biological sciences).