Humans originally had brown eyes until genetic mutations started making variations. No two eyes are identical, not even your own.
Your eye color & design is as unique as your fingerprints. Several gene variations all contribute to giving each of your eyes a particular design and shade of color (or colors plural if you are heterochromatic) that nobody else has. Not even your own two eyes are identical. Originally all humans had dark brown eyes (along with dark brown skin) which helped to reflect some of the harsh rays from the sun. As groups of humans migrated out of Africa and up into Europe, where there are seasons with less sunlight and the land is further away from the direct sunlight of the equator, there was no longer a need for so much protection from the sun’s harmful UV light. This is where the first mutation in human eye color took place. Sometime between 6,000 and 10,000 years ago the first blue-eyed person was born, from which all other blue-eyed people are descendant.
Our skin and hair is colored using the brown pigmentation called melanin. The back of our irises also contains melanin which gives our eyes color. Melanin is brown, and so brown eyes using brown pigmentation is easy to understand. Light enters the iris, the melanin absorbs some wavelengths of light and reflects back out the necessary waves to make the color brown, making brown eyes brown.
You would think then that blue eyes use blue pigmentation, but they don’t. Blue eyes use the same brown pigmentation as brown eyes but in lesser quantities. The other trick is that, since eyes are three dimensional, blue eyes absorb and scatter waves of light differently than brown eyes. The longer light wavelengths (reds & oranges) get broken up inside the eye and only the shorter wavelengths (blues) get reflected back out making blue eyes look blue. This scattering effect of allowing/blocking certain wavelengths is also what gives the sky color.
Brown, blue, gray, hazel, green – all eye colors use some amount of brown melanin combined with various ways of scattering & absorbing light to make whatever color the eyes are. Depending on the severity of their condition, humans with albinism can lack the necessary pigmentation to make their irises as opaque as other people’s. Irises that fail to block excessive light from entering the retina can cause a variety of vision problems including extreme sensitivity to bright light.
What does eye color “do”?
As for any potential purpose, eye color doesn’t “do” much. Unlike other genetic traits which evolution embraced because they helped our chances of survival, eye color variations seems to be largely perpetuated through romantic desirability. People find certain eye colors more attractive and so the genes for those colors live on. Your eyesight isn’t any better or worse because of a certain color eyes. Light travels through the pupil to the retina and so the color of the iris doesn’t change what you see. This is why cosmetic contact lenses can change your eye color without changing what you are seeing – they are only covering the iris.
There are some minor effects of having different eye colors. Because of how light is scattered and absorbed inside the eye, lighter colored eyes are sometimes more sensitive to bright light leaving some to squint more as well as needing to wear sunglasses more frequently. Driving at night can also be difficult because the glare from oncoming traffic can be more harsh. People with light colored eyes are more likely to develop macular degeneration, but people with brown eyes are more likely to develop cataracts. Finally, people with light colored eyes tend to perform better in sports where they control the hand-eye coordinated action such as in bowling, golfing, pitching, etc. Brown-eyed people tend to be better at sports where they react such as hitting a ball, boxing, playing defense, etc.
Added info: Getting reliable statistics on eye colors is difficult. That said brown eyes are the most common color type in the world at somewhere between 55-79%. Gray eyes seem to be the rarest at less than 1%. The eyes of some babies start out as blue but eventually become green or brown as their eyes develop more melanin. Few blue-eyed babies will have blue eyes as adults.
Liz Taylor was said to have violet eyes, but in reality she had blue eyes but with a genetic mutation to have double eyelashes which made her eyes look more purple. David Bowie was known for having two different colored eyes, but this was also an illusion. When he was 15 he got in a fight over a girl and his left eye was damaged leaving the pupil permanently dilated. This gave the impression that he had one black eye and one blue eye, but in reality both of his eyes were blue.