I was struck by this recently when reading a not-atypical defence of the expenditure on CERN, home of the Large Hadron Collider, by saying 'the biggest impact of CERN on humanity has not been the discovery of the Higgs boson but rather the invention of the World Wide Web.' The author went on to point out how much commercial business the web generates.
I'm afraid this is both iffy justification and bad history of technology. I'm not doing down what Tim Berners-Lee achieved. But the web, or something like it, was a technology waiting to happen. The internet was already well-established. The whole idea of hyperlinked documents goes back to Ted Nelson's work in the mid-60s. The architecture might have turned out subtly different, and CERN certainly kickstarted things, but something like this was on the (hyper)cards.
It's difficult, but I think scientists need to be brave and should not try to justify this kind of work in terms of its spinoffs, any more than NASA should try to do this in its occasional feeble attempts to excuse expenditure on a space programme by the spinoffs. We should be finding out about our universe because it's what makes us human and makes life worthwhile. Let's celebrate pure research, not try to turn it into a weakly argued generator of novelties.