There’s no way your state labor department or insurance company is going to pay a premium for US workers to train for and work a dead end, low satisfaction job updating 50 year old COBOL or 20 year old J2EE. So they contract out the work on-prem or setup a technology center in Nowhereville, New Mexico to grease the skids and make the hiring process work.
The reality is, without the H1 folks, those jobs would just be outsourced abroad anyway. The calculus is easy: the company benefits from greater control, the country collects taxes from people who may not ever collect benefits, and we get a pipeline of skilled immigrants.