Because a good developer at 22, becomes a even better one at 25, and even better one at 30.

Why? Experience matters. It is not just about the ability to write lines of code, doing all nights, and getting lots of "stuff" done, it is about the ability to write (and remove) the right stuff, and not wasting time with things that don't matter. It is the ability to guide, teach and mentor other people, and the ability to see when something might/will not work.

This comes only through experience and time. Experience to ship multiple large features and products (some products might take years to finish off), and see what works and what doesn't.

Sure, a bad dev. with 10 years of experience is worse than one with 2, but a good engineer with 10 years of experience will probably be more effective than one with just 2 years of experience.

Let me give you some real world examples:

1. In many states you can't rent a car if you are under 25. Why? Because rental car companies figured out that the human brain is not fully developed and reaches maturity until 25, and younger folks are prone to be fickle, take unneeded risks, and get into reckless accidents more often.

2. The Roman army had three units: The Hastati (young/inexperienced solders) in the first line, principate (more experienced folks) forming the second line, and the battle hardened triari forming the third and final line.

They figure out that just physical strength was not enough, and experience was more important. Aka, you can't be just good at swinging the sword, but composition, battle formations, tactics were more important, and the more experienced you were the better solder you were, hence the best soldiers were kept on the third and final line.

3. A bad doctor or lawyer can be bad at any age, a but a decent one becomes better and better with experience. (lots of different cases can form predictable patterns over time, and experience counts).

4. Plenty of young soccer players are really good at playing soccer, but can be terrible at coaching/teaching it. Some of the leading/coaching abilities come only through time and lots of life experiences.

I can give you countless other arguments, but the final gist is: if you are good with 2 years of experience, you become even better with 10. And some companies don't want people that just code/write features, but they need also the people that will guide large projects, know when to remove things, and teach/mentor other folks around them. And those abilities come only with sheer experience.

At Spotify we had a desirable ratio of 1/3/3. One lead engineer (usually with at least 7 years of experience, 3 with 3+ years of experience, and 3 with little/no experience).
The senior ones could guide the more junior one into doing things, but the lead one were expected to see the upper view of a project (i.e. not just the trees, but the forest), and help steer the architecture on the right directions.

When we had too many junior devs. in one team they tended to be ineffective usually by: slow at producing things (deer on the headlights syndrome), buggy features, bad architecture, creating frameworks that were totally pointless, and my favorite: in-fighting between devs, usually over trivial things on code reviews which rendered the teams totally ineffective.

So, you can see that some companies want to maintain the right ratio of "young guns" vs "experienced folks", and hence some might want people with more real life experience for some positions.

When I worked at Yammer, I remember the exec team refused to hire junior engineers initially, because it proved to be a time wasting exercise and they tended to require more time from senior devs. to be guided, than the value that they produced (by doing and shipping the right features).

Now there are always exceptions to this rule, but usually I learned that the exceptions were kids that have been programming since they were 13-15, and when they graduate from college they are equal to somebody that has about 2-3 years of work experience.