in the case of mainframes the main reason would be that nobody wants to learn cobol anymore and maintainers of legacy code are litarally dying out.
I think the issue is more exactly "nobody wants to learn cobol at that price". Lots of people found a passion for JavaScript and React in the last years due to the salaries.