Two wrongs don't make a right.
Firstly, they bought wholesale at a discount from the publisher, then sold ebooks AT A LOSS to undercut their competitors. This is called "dumping" and, well, the goal was to build a monopoly.
This is indeed frowned upon, as dumping is usually done with this goal. It is actually illegal in some countries, but in the US it might not be, or has some kind of exceptions. But then, if it is illegal, the publishers could've simply taken Amazon to court instead of trying to go all Judge Dredd on them.
But price-fixing is actually illegal in most countries, including the US. And it seems that they were making it such that they could simply point that it wasn't price-fixing, simply that they couldn't sell for less because of Apple's MFN clause. In reality, they were colluding with Apple, having the price point set higher than what Amazon was getting, thus forcing the market to go much more expensive. And while dumping hurts the consumer in the long term (when the monopoly is established and prices are jacked up), price-fixing hurts the consumer immediately.
Apple deserves to be punished for stooping so low.