Layoffs are bad because they are deceptive and cruel to those laid off and further erode trust from those not yet laid off. They are deceptive because being hired as an employee traditionally carries with it implied permanence that being hired as a temp or contractor (like your plumber) does not. You have a job unless and until your performance provides cause to fire you. They are cruel because they take advantage of the inherent power imbalance between employer and employee. The employee may be here on a visa, or just moved their family across the country, or has debts and obligations where he requires employment. He is harmed if the company suddenly and unilaterally ends the relationship. The company on the other hand is not materially harmed if the employee unilaterally decides to leave.
You can argue that a company is legally allowed to act in bad faith, but “barely within the law” is not a high ethical bar.