I've known people working in federal government where firing them would be a serious problem, as in they're the only person who knows something quite important well enough.
Many of these people could get paid more in private industry. You're seriously underestimating niche knowledge of things and/or overestimating how well things are documented.
> they're the only person who knows something quite important well enough.
Then either the organization needs to abandon that 'something' or create a structure that prevents such a situation arising.
If that 'something' is important then the organization has to provide some sort of guarantee of continuity or it is permanently just one road traffic accident from disaster. If it won't do that then it is tacitly admitting that the 'something' is not important.