It's that "creative destruction" of free market capitalism. Pilots are not alone -- e.g. there are all the IT folks whose jobs are going to India.
But the airline situation is particularly bad, since they tend to go on and on in bankruptcy zombie land for ever, instead of winding up the business, selling the assets and discharging the employees to either obtain work with another airline or make a more drastic career change.
Bankruptcy courts are a bit on the puzzling side. For example, one court ordered the airline's catering company to keep providing food without being paid. Imagine the catering company's surprise that they, too, went bankrupt.