Referring here to contractors as the body of private sector contract organizations that had outsourcing contracts for various support roles, not the individual people. Speaking to working environment.
This varies by agency and field. The older pension system was replaced with a newer model a while back so a prospective federal employee is looking at the combination of effectively a 401k, a pension of 1% top salary per year of service, and social security. That’s not bad but your salary is capped at under $200k so you're not getting anyone with IT skills turning down FAANG positions unless it’s for a cause they support (NASA, the VA, etc. can do that a lot more effectively than Agriculture, etc.). In other professions, of course, that can be pretty different – if you’re an academic who isn’t able to/interested in switching careers to ad-tech, that might be a great job compared to getting in a cage fight for a handful of tenure-track positions.
This matters a lot for security because the defense needs to be everywhere. NASA will never run out of people who want to work on robots because rovers are cool; the IRS needs people who can modernize internal business systems and that’s not only not cool but will get mockery from the more clueless people they know.
The government is able to employ tons of smart people that could be making way more money elsewhere.
They might not get the absolute best security people in the world, but they could get good enough - as good as they're getting from MS for a fraction of the price.
Additionally, government salaries aren't terrible when you factor in the pension. Most people want the money now. But if you want financial security in the future - that's a reason a lot of people chose to work for the Fed.