Your question can be handled by splitting into two sub-questions.
Why use years of experience as a requirement?
Because it's an easily-verifiable metric correlated positively with programming competency. Snagulus's answer already elaborates on the details of correlation, so I'll focus on the "why".
The hard truth is that usually there is more than one candidate for a given position. Also, interviews are quite resource-consuming, especially if they are done "properly", i.e. technical interviews are conducted by technically-competent staff (in this case programmers).
Therefore, some criterion to initially sift through the incoming CVs needs to be used, and preferably one that can be verified by non-technical staff - when in doubt, HR people can always call previous employers and check that yes, John Smith has worked for X years with them.
Why not use "passion" as a requirement instead?
There are at least two problems with this:
how to measure "passion"?
KLOCs logged? Good luck finding that out, also, in programming (and other disciplines), more profuse does not equate to "better".
Open source/hobby projects completed? Not easily checked by HR, and a lot of competent programmers have legitimate reasons to be inactive in that regard - other time-consuming obligations, long work hours with desire to unwind, simple professional fulfillment during work hours etc.
Years of experience? Oh, wait...
is "passion" really a good metric for competence?
As Robert Harvey says in his comment, passion is not really indicative of a competent programming. Compared to experience, it's a mostly orthogonal quality - that is, there exist :
- passionate and competent programmers and
- dispassionate and technically competent programmers and
- passionate and technically incompetent programmers and
- passionate and non-technically incompetent programmers,
- etc. etc.
The last example is important in our context - years of experience also show that a given programmer has somehow managed to function in his/her job, whereas an dysfunctionally passionate programmer could, e.g. flat-out refuse to participate in even the simplest task management system (say, Scrum Post-it notes), because "it slows me down."
First of all, and fortunately, "years of experience" are often evaluated "loosely" - i.e. if you are applying for a job with language X, but only have "commercial" experience with language Y, similar to X, that is also often taken into account.
Secondly, personally I'm not a fan of "N years of experience", and I'm not the only one. There is a simple alternative - specifying "experience in". That usually suffices as a filter, since candidates are forced to document that experience in their CVs - if you get a candidate for a programming position that has previously only done waitering (and this happens!) you know something may be wrong.