The benefits were legendary but the pay was 20-30% lower than what was around.
I don’t have evidence of wrongdoing but I’ve occasionally wondered if it was some kind of scheme.
Stock compensation is completely ignored. Since stock compensation can be a large fraction if not the majority of the compensation, this means that many H1-Bs may be underpaid compared to their coworkers, while appearing to the government to be the highest paid in that company and job role.
The other ignored aspect is effective hourly pay. Software engineers are nearly always exempt employees, so they don't receive hourly pay. But a manager can demand more from H1Bs, even if it would mean work during nights or weekends, and there's little the H1B can do. Local employees can more easily change jobs if that happens, and moreover, the threat that they can change jobs disincentivizes such abuse.
Even if you try to pin it to the median that does not include H-1Bs, you still are letting the market compete on labor cost and that competition can still affect the local median. Companies decide all the time that they could hire, for example, 2 H-1Bs for the cost of one "senior" local developer, encouraging that local developer to maybe only ask for 1.5x "an H-1B" to remain competitive in that market. Iterate that enough in hiring decisions and companies still have more control of that local median than labor does.
I don't know if there is a "fair" way to set the cost of labor for an H-1B, but "local median" or any other average-based math is probably not it.