No, it's definitely illegal/against the rules to deliberately pay an H1-B worker less than a native worker in the same position. That doesn't stop anyone from doing it. The program depends on the visa holders to report any wrongdoing; however, I think we all know what would happen should they complain. H1-Bs are considered even more disposable than your average worker, and have a fixed amount of time after being terminated to obtain new employment or face deportation. They keep their mouths shut, and keep getting paid less.
Think about it, why else would a company employ an H1-B? They will scream and cry about a shortage of native workers to fill open positions, but they're full of shit. There are more than enough native workers to fill the positions; there just aren't enough native workers available at the salaries they want to pay. So, in a sense, they're not lying about a shortage, but it's a shortage of their own creation. That, and frequently a company will identify an H1-B they want to hire and write a job description so specific to their skill set that they can claim there aren't any qualified native workers. Which is true; nobody has the exact same skill set as someone else.
H1-B visas exist to exploit foreign workers and put more expensive native employees out of work. Period. It's a giant scam. But, since companies are sociopathic by their very nature, they do whatever it takes to save money.