Two of the biggest news events of the past year have been the leaks about top-secret snooping by the NSA and the disastrous rollout of Obamacare. But in an important way, they are both manifestations of a story that has been unfolding for decades — that of a federal government that has outsourced too much of what it does to private contractors while allowing the quality of its own workforce to atrophy.

Lots of Americans were disturbed to learn from Edward Snowden that the government is keeping track of their every phone call and text message. But they might have also wondered why a 30-year-old government contractor in Honolulu, with security clearance that was approved by another private contractor, had routine access to some of the government’s most sensitive secrets. Even worse, two years after Pfc. Bradley Manning did the same thing, Snowden managed to download millions of pages of documents from a computer system designed and managed by private contractors without setting off a single alarm. The whole affair was an embarrassment to Washington’s government contracting sector.

So, too, the fiasco with HealthCare.gov, which despite the bleating of Republicans has almost nothing to do with the wisdom of the new health-care law and everything to do with the way the government and its outside contractors set about implementing it. While several of the contractors failed to perform as promised, in hindsight it appears the government also made a crucial mistake in deciding to rely on the IT staff at the Centers for Medicare and Medicaid Services to manage the contractors and oversee the final integration of the new system. Free-market ideologues will reflexively see in this failure further evidence of the inherent inferiority of public-sector workers. In truth, it is evidence of how outdated civil service rules and ill-conceived caps on the size and pay of the federal workforce have eroded the government’s ability to perform even essential government tasks.

The federal government has long relied on outside contractors to provide it with weapons systems and other goods. But starting with the Reagan administration, there has been a determined shift of work from government employees to private contractors, on the theory that they could do it better and cheaper. For a time, that was true. Much of the early outsourcing was for lower-skilled clerical and maintenance functions for which government workers received pay and benefits well above the market rate. Or it was for the design and operation of new computer systems that automated the work of government and had never existed before.

But in recent years, much of the outsourcing has been driven by politics and ideology.

To demonstrate their commitment to “shrinking” the size of the federal government, both Republican and Democratic politicians set about shrinking the federal workforce and then capping it at 2 million workers, despite continued growth in the economy, the size of the federal budget and demand for government services.

“This obsession with small government is a sham,” declares Daniel Gordon, who headed the Office of Procurement Policy in the first Obama term before joining the law faculty at George Washington University.

Not only are there caps on the number of government workers, but there are also caps on government pay that ignore the realities of the marketplace — and that, too, has driven the outsourcing trend. It may be politically popular in a country where median household income is $51,000 to require that no federal employee should be paid more than the $174,000 earned by a member of Congress, but it makes it pretty hard for the government to recruit and retain the lawyers and economists and biochemists and software engineers it needs when they can make double and triple that in the private sector. So it’s no surprise that the only way that government managers can fulfill their mission is to outsource its brains, shifting high-level work to private firms that have the flexibility to pay their workers market rates.

In the end, taxpayers are not only indirectly paying the higher salaries they refuse to pay directly to government employees — they also wind up paying for the contractors’ profit and the costs of winning and managing contracts.

Government employees, however, must also shoulder some of the blame for the outsourcing boom.

If you give federal managers the choice of filling vacancies from the candidates who emerge from the government’s arcane recruitment and promotion system (and who, once chosen, will be virtually impossible to fire if they don’t work out), or you gave them the choice of handpicking whomever they want and hiring them under an open-ended “umbrella” contract with a private firm (with the power to fire them at a moment’s notice), nine in 10 would hire the contractor. And that’s exactly why you now find so many contract employees in government offices working side by side with government employees.

The system the government uses to recruit, hire, evaluate and incentivize its employees is seriously broken. And yet every attempt to reform it is bitterly opposed by federal employee unions, who take it as their mission to prevent good employees from being rewarded and bad employees from being fired. The result is that the unions are protecting ever-fewer employees with ever-lower pay.

Those open-ended IDIQ (for “indefinite delivery, indefinite quantity”) contracts, by the way, now account for anywhere between one quarter and one half of all federal service contracting, according to Gordon. Originally, they were designed to allow agencies buy smaller quantity of standardized supplies, or respond to the occasional surge in workload, without having to go through the long and cumbersome process of letting a new contract. But now they are routinely used by agencies for orders worth hundreds of millions of dollars that involve no competition, little transparency and dubious savings.

These clever work-arounds to the government’s personnel and contracting systems have driven the rapid growth in government contracting, much of it here in the Washington region. Federal contracting grew from about $200 billion in 2000 to about $550 billion in 2011 before falling back to $450 billion last year. Sixty percent of that was for services. By some estimates, there are twice as many people doing government work under contract than there are government workers.

Against that backdrop, hardly anyone considered it remarkable that the government would have outsourced the day-to-day operation of its most secretive computer system to Booz Allen Hamilton, the agency’s leading contractor. Nor, during the homeland security push after 9/11, did anyone question why a company such as USIS, which was originally spun off from the government to do simple background checks for new employees at departments such as Agriculture and Education, should be doing investigations for top security clearances normally done by the FBI. After the Snowden affair, the government sued USIS, accusing the firm of pushing through clearances without sufficient investigation in order to qualify for performance bonuses.

And long before the botched rollout of Obamacare, even the Professional Services Council, the leading trade association for federal contractors, was complaining publicly that too many agencies lacked skilled workforce to manage the contracting process — in particular, contracts for complex new computer systems. Numerous agencies had turned to outside contractors to manage its outside contractors before Gordon issued an order in 2011 declaring contract management to be an “inherently government function” that should be done only by government employees.

What Snowden and HealthCare.gov have made clear is there is a limit to how much outsourcing can be used as a work-around to the problems of dysfunctional government. It’s time — actually, it’s way past time — to fix the underlying problems.

Up to now, the Obama White House has made the calculation that it’s not worth the political capital to take on the public employee unions over civil service reform, and its not worth the political risk of challenging the tea party Republicans to push for an increase in the size of the federal workforce. Given what’s happened, maybe it’s time to recalculate.