The director of CBO reminds us
A leading argument in favor of federal support for . . . technology R&D holds that because private developers of scientific and technical innovations do not capture all of the benefits from their discoveries and inventions, private investment is lower than would be justified by the magnitude of its benefit to society.
In a globalized economy, the job-creating benefits of technological advances are predominantly enjoyed where labor is cheapest instead of where the technology was developed. This inability to reap where we sow undercuts the traditional argument for US government investment in R&D and goes a long way to explaining why China has leapt ahead of the US in green technology development. Indeed, because of free trade agreements, it appears that private developers are now generally better able than governments to capture the benefits of their R&D investments.
Here is a longer post on forces influencing where innnovation occurs and where the benefits are distributed.