Part of the problem is that in many fields it is quite difficult to actually quantify how much value or benefit an individual employee provides to a company or organization (and this is a bigger problem in larger organizations), but it's easier to measure aggregate productivity of groups.
So if you are a hard and productive worker, early in your career it's likely that you're being paid a lot less than you're worth, because your productivity is getting averaged together with other entry level folks, some of whom who are just doing the bare minimum, or who have figured out the secrets of "looking productive," or just really aren't cut out for the job and are struggling to keep their heads above water.
As you get older, two things happen. First, you accumulate a much longer personal track record that makes it easier for people to try to guess how effective you've actually been at past jobs (or at least makes them feel like they're doing a better job of guessing). Second, if you're extremely successful in certain fields you're likely to move into positions where it is going to be easier to assess your productivity individually (or, again, for people to feel like they're assessing your productivity individually, whether accurate or not).
I guess a second reason is that people don't respond well to extreme pay disparities even in the presence of extreme productivity disparities. A top programmer in the top 5% of their field could easily be 10x as productive as a programmer at the 50th percentile (a programmer in the bottom 5% of their field likely causes more problems than they fix). But it wouldn't be unreasonable for all three to be employed in the same office, and even if the top 5% programmer makes 50% more than the median guy, it's likely to cause a fair bit of resentment.*
Just remember that it's not that all old people make a lots of money, a lot of what you are seeing is the the disparities get bigger as people age. For every 55 year old pulling down mid-six figures, there are a bunch trapped in unpleasant and low paying jobs, or who would struggle to find work at all if they lose their current position.
*Assuming otherwise equivalent titles, skillsets, and ages.