There is still an element of captivity above what a citizen or resident faces--staying in country is contingent on quickly finding another employer who will sponsor you.
If a native employee is fired, they lose their job and probably go on unemployment while the look for another one.
If an H-1B employee is fired, they get deported.
Employers know this, and they treat H-1B employees accordingly.
Well, yes, but then you're just benefitting from lax de facto enforcement, not any de jure certainty. And anything de facto which operates below the standard demanded by de jure can change at a moment's notice, subject to politics, audits, or someone waking up on the wrong side of the bed.
There's a bit more safety than that. When you enter the country on an H1b, you get an I94 that is valid until your visa expires. If you then lose your visa (because you've left the company or got fired), you can still legally stay in the country until your I94 expires. The caveat is, an immigration officer can take away your I94 at any time, at which point you would be forced to leave. However, as long as you avoid immigration officers, you are not breaking any laws by staying and looking for another job.
If a native employee is fired, they lose their job and probably go on unemployment while the look for another one.
If an H-1B employee is fired, they get deported.
Employers know this, and they treat H-1B employees accordingly.