With H1-B, a worker is tied to a specific employer while they bide enough time (5+ years) until they can apply for a green card. During that time, the worker cannot switch jobs without reapplying for the visa. Thanks to per-country caps, many people have to wait for MUCH longer than 5 years to receive their green cards, during which time their employers have them by the throat. For those workers, losing a job means having to leave the country in TWO MONTHS.
https://www.washingtonpost.com/us-policy/2023/02/24/temporary-visa-h1b-tech-layoffs/