Another part is that if you hire an inexperienced programmer, not only do they have lower productivity than an engineer with 2+ years experience, but they lower the productivity of at least one other senior engineer that needs to mentor them and bring them up to speed. I'd estimate that mentoring a new inexperienced hire would at least half the mentor's productivity for a couple months at least. If you hire someone that's already worked a couple years, that lost productivity was paid for by a different company.
Another observation I had is that the upwards mobility is easier in between companies than within the company. The sad truth is, most companies only acknowledge your importance when they are about to lose you. If they consider you are comfortable in your position, they have no incentive to promote you. So assessing yourself against the job market periodically is a logical and practical way to keep your career path in check, regardless of your company.