It's not illegal just (possibly) shady, but there are ways to link the former company's liabilities to the purchaser in some situations in some jurisdictions. That may apply here but that's for a whole court to decide.
It's not specifically against a law but debtors who got shafted can choose to sue the "old" and "new" companies under a few broader laws, basically alleging "I had a valid contract with the old company but this sale is a sham transaction to get out of the contract and 'NewCo' is unjustly enriching themselves by screwing us 'OldCo' debtors." IANAL but my sense is such a case can be won but is far from a slam dunk and it will cost money and take time. Debtors will have to decide if they are out enough money to be worth sinking more money into recovering it. This kind of move might also be an aggressive escalation tactic in a hardball negotiation with debtors unwilling to renegotiate on acceptable terms. It's possible that the OldCo/NewCo people doing this may choose to leave certain assets in OldCo to make legal challenges less likely to prevail than if they'd completely emptied out OldCo.
Other impacts can include future potential NewCo lenders being pretty leery about getting involved with the same people. It's also not a great look for the founder(s)/senior execs in terms of future resume - unless there are extenuating circumstances which justify doing it. An example can be something like a fundamental disagreement between co-founders who are major shareholders. In that scenario this may not be to shaft debtors but rather for the majority co-founders, investors and key employees to 'dump' a minority non-cooperating co-founder who's no longer involved with the company, has a "change of control" veto and won't sell their shares but can't stop an asset sale. Basically the board approves the sale and the key execs/employees all vote with their feet. The original OldCo shareholders still own those shares, they're just worthless without the people, IP, assets, etc. In such a case, the non-cooperating shareholder might have grounds to sue but one defense can be a solid paper trail showing the company treated them fairly, offered to buy out their shares at fair market value and was basically forced into this as the only alternative.
This is why I said ostensibly. I think it should be assumed the financial parts were done on the up and up. Such that disclosures and such can waive a lot of the concerns that would make it illegal.