The pupil, the black spot in the middle of your eye, is actually a hole that allows light to enter the eye. Around this hole is the colored part of the eye, the iris, which regulates the size of the pupil and how much light is allowed into the eye.
The iris has pigment in it to protect it against light. Everyone has pigment at the rear part of the iris, but not everyone has it at the front. When a person lacks pigment at the front, this part of the iris is transparent, and absorbs red and yellow light waves. The remaining light, the blue waves, then bounces off the pigment at the rear of the eye, and gives the eye a blue color.
When the front part of the iris has pigment, it absorbs different kinds of light rays, and the light bouncing off the rear of the iris appears brown or gray.
Often a person has blue eyes when young, and brown eyes later in life, because it takes the eyes time to produce pigment at the front of the iris. Until this pigment appears, the eyes are blue.