Re: How is this kind of deal even legal?
Rubbish.
Remember, the business, instead of having a reserve of working capital (needed to operate) now has to rely on debt to fund operations. The underlying purchase debt is also a drain on revenue, lowering the overall profit margin. Unless the new owners (Ha!) are really very good, this means the business is now very susceptible to sudddenly going under in a downturn, as credit dries up.
So, to refute your points:
1) The employees suffer, either by the business going tits-up, or by having their pension pot raided (directly or indirectly).
2) Customers suffer. The business generally has to clamp down on cost, this means less service, less product range, less innovation.
3) You are correct. The original shareholders get paid.
4) The new owners don't necessarily get their suitcases by increasing value. They ensure, that even if they cannot offload the smoking shell to some other mug, they get paid anyway. Usually by charging high "management fees" or by awarding themselves large dividends, or by charging a "commission" on the original purchase. Remember the "Rover 4"!