It's a feedback loop - the better the pay is, the more people are after it, which lowers the pay, and so forth. This loop tends to be more disrupted in highly regulated fields (like healthcare), but there are other factors too. For instance, in my country, an important reason for the shortage of doctors and nurses is simply that they can find a better pay and more humane working conditions abroad, and so they emigrate.