Back at the beginning of the coronavirus pandemic, many experts cautioned that a potential vaccine might take years to develop, if one came at all. After all, the previous world record for vaccine development was about four years, and most of them had taken over a decade.

That turned out to be wildly mistaken, and particularly in the case of the messenger RNA (mRNA) vaccines. The Moderna vaccine was built over a weekend, while the Pfizer/BioNTech team developed theirs in just a few hours. Then after clinical data came in, we learned that both treatments were astonishingly effective — some of the best vaccines ever created.

Science seems almost magical sometimes. But what has gotten less attention is how many of the pioneering scientists who painstakingly worked out the kinks in mRNA research survived for years on relative scraps, begging for funding in order to continue their work. These vaccines prove that wild ideas and repeated failure are a key part of scientific success.

Gina Kolata at The New York Times profiled Dr. Kati Kariko, a woman who immigrated from Hungary to the U.S. and has been studying mRNA for decades, with her career hanging by a thread for most of that time. "She migrated from lab to lab, relying on one senior scientist after another to take her in. She never made more than $60,000 a year," Kolata writes.

Her career is a lesson in how bad priorities have corrupted the process of science funding in this country. What investors and grant committees (from federal science agencies, foundations, and universities) want, by and large, is splashy headline results as fast as possible. The things that tend to get money are thus ideas that are aimed to fix some concrete problem immediately — above all, ones that can produce a valuable patent.

It's the logic of neoliberalism, which has penetrated deeply into universities and the federal science agencies: Just as with business investment, research should be funded only if it can produce something immediately useful or profitable. Scientists who are simply curious about fundamental scientific processes, or have some implausible utopian idea that would take years to develop, tend to be put at the back of the line — not always of course, as there are many thousands of scientific grants, but in general.

The problem is that a businesslike attitude is totally at odds with how science works. Most obviously, the viability or usefulness of a piece of seriously innovative science cannot be known in advance. What's more, the process of that kind of science is usually long and winding. Eureka moments where some big problem is solved overnight are very rare — more often, researchers have some results that don't make sense, or some vague suspicion, or a fresh theory, and then they spend years banging their heads against the wall trying to figure it out. Especially as science has become dramatically more complicated and arcane, this can take decades of painstaking work, failing over and over and over again, as researchers run into dead ends and eliminate wrong explanations.

This is exactly what happened with Dr. Kariko and her colleagues. They started with a wild-eyed theory that mRNA could instruct cells to manufacture particular proteins. Others in the field scoffed, but after some trial and error they got it to work. Then they tried to use the idea in actual living tissue with a treatment designed to prevent strokes, but failed repeatedly — instead the mRNA caused a huge immune system overreaction.

That failure, however, turned out to provide a vital lesson. The immune system problem stumped them for awhile, but eventually by examining the control group data in one failed study, they figured out that their control treatment (with a different kind of RNA) contained a molecule called pseudouridine that cut the immune system response. If they stuck that into their mRNA, hey presto, they could instruct cells to make about any kind of protein.

Even then, it was hard sledding to get funded. "We both started writing grants," Dr. Drew Weissman, Kariko's longtime collaborator, told the Times. "We didn't get most of them. People were not interested in mRNA. The people who reviewed the grants said mRNA will not be a good therapeutic, so don't bother." Whoops!

Now, Moderna did eventually step in to fund Kariko's research — with a lot of help from the National Institutes of Health (a federal agency). But again, this was only after most of the lonely, unglamorous work had been done, and the promise of mRNA technology was obvious for those with eyes to see.

One can understand why private investors would be most interested in something that looks likely to be profitable. Their pockets are not bottomless, and their investments must pay off eventually, or they will go bankrupt. But that makes it doubly important for government research money to go to fundamental science: the weird ideas, the crazy moonshot stuff, and simple investigations into empirical reality. There are thousands and thousands of discoveries and inventions that were developed at least in part with federal science money — the computer, the internet, GPS, weather radar, vaccines for HPV and hepatitis B, just to name a few. In practically every case of success, the trail there was littered with scores of failures.

All this casts Republican complaints about "wasteful" government spending on science in a new light. For years now, more libertarian-minded members of Congress like Sens. Rand Paul (R-Ky.) and Ted Cruz (R-Texas) have regularly dug through the grant lists of the National Science Foundation and other research agencies to mock studies they think sound dumb or politically incorrect (usually mischaracterizing them in the process). This kind of thing is not just stupid, it is dangerous. It's part of why federal science is on the back foot, and why the NSF puts out regular press releases celebrating scientific discoveries funded by their grants.

Funding research that works is good, of course. But the government should also be proud of putting money behind science that doesn't work out. Failure is an inescapable part of good science. If we only funded studies that sound promising to the most dimwitted scientific illiterates in Congress, we'd never have gotten the mRNA vaccines today. And for every Dr. Kariko that managed to hang on, there are surely dozens of scientists with brilliant ideas who couldn't find money and gave up. There could be dozens of miracle cures we've missed over the past 30 years. Let's not make that mistake again.