According to MJ Boskin, former economic adviser on George HW Bush’s Council of Economic Advisers:
Private markets invest too little in basic science,” he writes, “because private investors are unable to appropriate the returns.
More at Project Syndicate
At one level, this is subsidies for beer guzzling students to put their heads towards scientific advancement. It may also involve direct handouts to firms (generally not preferred by economists because there is too much risk of waste in a “picking winners” approach) and regulatory or tax/subsidy approaches which shape the competitive environment (a carbon tax, for example, stimulates research in clean energy).
Because other people benefit, a 100% greedy individual will underinvest in effort, because they only care what benefits accrue to them, and not other people. So the government needs to pick up the slack by providing incentives.