I mean yea, every corporation in America knows this. When these systems were written, you could hire a dozen COBOL devs for pocket change and some string. Nowadays a single COBOL dev who can seriously work on these systems is likely to cost half a million per year.
I work in a fortune 500 company that doesn't make money from technology so it's largely immune to the current tech downturn. They've been banging on the drum of, "off the mainframe next year" for 30 years at this point. We're still using the fucking mainframe and we're still using fucking COBOL. If corporate America is struggling with something, it'd perhaps behoove the DOGE people fucking around with our technical infrastructure to stop and think, "Maybe this problem is actually much harder than we thought?"
So you're right but you're also wrong. Putting aside DOGE for a moment, the following things are reasonably true.
There are four main killers of project rewrites. And it's why rewriting a product is often considered a trap.
1. Scope creep. Instead of hitting the same target now you have to hit the same target + 20 features to replace it. And if the old code is not feature frozen, that list ever grows. It's often not enough in corporate America to replace an ancient system with a modern one that runs the same but faster/saner.
2. Insufficient understanding of what the system does and how. If someone wrote a black magic module nobody understands and everyone is terrified of trying to, it's a problem for maintenance but also replacement. This fear keeps some legacy systems in scarily critical places. It also can mean nobody actually knows how many 100s of things the old system does.
3. Quarter shareholder return. Rewrites don't produce new profit. They cost money. In the short term they do not benefit shareholders of the stock. Corporate tech America hasn't cared about the long term in decades.
4. Office politics and the people who work on the old system absolutely fucking over the new project to keep their jobs.
For legacy government systems I can nearly promise you 1 could be dealt with if someone had the spine. 3 is not really the issue. Although selling it to whoever you answer to might be. Spend a million this year, save 5 million over the next three years only works when buzzwords and the newest hype that won't deliver are involved.
2 is a fucking nightmare and quite likely a big part of the problem.
4 is also guaranteed a problem it's just govt internal politics are slightly different looking/flavored than normal private sector ones. But they exist and lots of people make a shit ton of money by intentionally fucking over other govt contractor they're supposed to be integrating with and playing very stupid games with taxpayer money. Nevermind the jockeying for favor that happens within the upper echelon of any govt agency.
DOGE won't solve either, not reasonably. On the other hand anyone who follows my posts knows I have 0 faith our government will keep the lights on as it is and most critical systems we have now are already failing, fucked up, or unable to do their purpose anymore. At some point setting the dumpster on fire is the only way you'll ever be rid of it. Will it suck? Sure. Do I care anymore? Not really. Would it be nice if anyone competent and capable of solving it existed? Sure. I also want a unicorn parade on my lawn.