I have green eyes. What you see in my eyes is not the same thing that scientists see in them. The current thought behind green eyes is that a thin layer of yellow pigmentation overlays the "blue" color of an iris, and the result is a yellow color.
The gene responsible for this yellow pigmentation is completely separate from the brown/blue gene; thus, to have green eyes, one must have a low concentration of melanin in the iris and produce the yellow pigment.
Here is a chart that demonstrates how melanin in the front and back epithelia of the iris and the structure of the stroma create eye color. You will notice that the specific combination which is required for green eyes is more complicated.
Of course, we're talking about gene networks here so in reality this isn't cut and dry as I made it sound. If it was, there were be a higher percentage of the population with green eyes.
Eye color is complicated than many may think and the combination required to be born with green eyes is rare. And it has been an area of study for scientist for decades. A lot of people tend to tell me it is because of X or Y, but they are just using layman's terms to try and explain something that they are ignorant about. In other words, anyone who says they know definitively isn't being completely insightful or in other cases honest.
Eye color is highly polygenic and not entirely understood.
A lot of genetics is not as simple as Mendel's pea experiments might lead you to think. Mendel figured the basics out mostly because he picked traits that have distinct, qualitative phenotypes that were only controlled by the expression of a single gene.
This tends to be the exception rather than the rule, but it's still taught in schools because it provides a clear simplified way of explaining the mechanism of why traits are passed on or not.
It is more likely that many different genes play a role in determining eye color (which is a spectrum of colors really, not just "green" or "blue"). While some of the Brown vs. Blue in European populations genes have been worked out (OCA2), the mixtures that make up intermediaries are not entirely clear. What would start off as a binary state becomes very messy when you start adding in 11 other SNPs with incomplete penetrance and variable dominance terms.
As for the rarity, that's just simple population genetics.
The alleles for green eyes, whatever their nature, are simply less common in European and Middle Eastern populations than brown or blue. Hence, they are less likely to be observed.
Since eye color is usually not selected for or against when people choose whom they wish to mate with, the frequency of the "green allele" remains more or less the same. Though I did have a boyfriend tell me once that he was only together with me because of my eye color. That sort of creeped me out and I dumped him a week or so later.