When hair turns gray or white is is because the pigments fade out, but why they do so is still being researched and we may not have the final answer yet.
As the hair is being formed, melanocytes send pigment (melanin) into cells with keratin in them. Keratin is the protein that makes up our hair, skin, and nails. Throughout the years, melanocyctes continue to inject pigment into the hair’s keratin, giving it a colorful hue.
When you get older comes a reduction of melanin. The hair turns gray and eventually white.
If you are keen to learn more, may we recomment the Library of Congress website Everyday Mysteries
Other good websites on this topic:
American Academy of Dermatology (AAD): Public resource center - Articles about hair loss, hair health, and hair facts.
How Stuff Works: How hair coloring works - Learn how hair coloring works, along with general information about hair and ingredients of hair coloring products.
San Francisco Exploratorium: Better hair through chemistry
Description of the biology of hair, what it means to color your hair and fun activities to do with your hair.
Kidshealth: Say hello to hair - This site from the Nemours Foundation is directed at kids and describes the biology of hair.
L’Oreal Hair Science - “All the answers to your questions about the hair of the world: Composition, growth, loss, color, shapes, types, and properties.”