I am sure there are plenty of specialized functions that are hard to replace, but many are just applications that "do things the way they have always been done".
Never mind they can can now be outsourced better and cheaper. How many times have you heard of government agencies spending millions on upgrading systems that are essentially CRM systems, or even worse, payroll systems and the like?
I've also seen private companies go through great pains to "upgrade" systems, to replicate arcane "business logic", which could be more easily solved by changing the process to achieve the same results. (One little example - why track 5000 sales districts, sales, etc - to calculate sales commission levels. Just assign territories, count sales, run it thru a function and be done.)
Back to another government example - why is it so important that role be taken every single day, for budgetary re-reimbursement? (sure, keep role to make sure no kids go missing, but what does that have to do with the cost of running a school? The lights are still on, the heat/AC is running and the teacher is there if there are 18 or 32 kids in the class.)