When poets compare beautiful eyes to the sea or sky they're probably not aware how accurate they are being.
In each case the color is a product not of pigments but the scattering of multicolored light so that only the blue reaches the observer. On a clear day sunlight scatters off molecules in the atmosphere, but does so more at short wavelengths. Blue light is scattered almost ten times as effectively as red.
As Paul Van Slembrouck explains in this Medium piece (with drawings) irises of people with blue eyes scatter the light back in the same way. If the light falling on the eye is white, that is contains a mix of wavelengths, it is mostly blue that will be reflected back for others to see. Indoors, with light that may be skewed to the red end of the spectrum, eye color may seem to change, since there is no longer enough blue to dominate.
Humans are not the only creatures to put this phenomenon, known as structural coloration, to use. It is common in marine creatures, insects and birds.
Brown eyes have much simpler physics. The stroma, or front layer of the eye, of brown-eyed people has plenty of melanin, the same pigment that makes for darker skin color. Most light falling on the eye is absorbed, and we see the little that is reflected as brown.
Hazel eyes have less melanin than brown. Most light is absorbed, but enough is reflected for there to be a moderate amount of scattering, creating a color that mixes brown and blue. Different pockets of the eye may have different concentrations, creating dappling effects. Green eyes sit further along this continuum, with just a touch of melanin shifting the color subtly from blue. Dark specks in either case often represent are usually the rear layer, or epithelium pocking through.
Grey eyes however, represent something different. They lack melanin but instead have deposits of collagen in the iris. These particles, being larger, scatter wavelengths more evenly (Mie scattering) to give a mix of colors. The analogy here is with the water droplets in clouds. Enough light is absorbed, rather than reflected, to make irises resemble rainbearing stratus clouds rather than white cirrus streaks.
Many babies initially lack melanin, even when they will eventually have brown eyes. Their blues are deeper in color than grown-ups' because even the most blue-eyed adults have some larger particles in their irises that scatter a range of colors, diluting the blue effect.
The other side to this is the genetics that produce these colors. Mendelian genetics are taught using the gene for brown eyes as a dominant and blue as recessive. Other colors are usually waived away. In fact there are multiple genes that determine eye color, although blue eyes are thought to be traceable to a single ancestor. The neighboring OCA2 and HERC2 genes do most of the work determining melanin levels, but others are presumed responsible for factors such as collagen presence.