Pilots for large airlines are paid very well (100k-200k+). The training is expensive and time-consuming, but not that expensive or that time-consuming, if we compare to e.g. medicine or science.
There is a low-paid and debt-heavy portion of the career. However, Medical students aren't paid and even the lowest-paid pilot is making more than the average phd candidate.