
Not every cell in the body produces melanin - skin cells that do, are called melanocytes. In most people melanocytes are spread evenly across the skin, but some people have melanocytes in clumps in the skin. These clumped melanocytes don't produce the UV-protective eumelanin, as they have a mutation in a gene that is essential for regulating the proportions of pheomelanin and eumelanin. Usually this proportion is controlled by a hormone called melanocyte stimulating hormone (MSH). This hormone binds to a specific receptor on the surface of the melanocyte cell called MC1R (A in the illustration on the right). When MSH binds to MC1R signals are sent into the cell to turn pheomelanin into eumelanin. When there is a mutation in MC1R, the MSH can't bind to it, and pheomelanin isn't turned into eumelanin (B in the illustration on the right). This causes the reddish colour of freckles.
The MC1R mutation is dominant, meaning that you only need one copy of the gene to have freckles. However, red hair is a recessive trait, which means that you need two copies of the MC1R gene to have red hair.
A recent interesting paper has determined that variations in MC1R caused variation in hair and skin pigmentation in Neanderthals on a scale that is observed in modern humans.1
If you want further information on skin pigmentation and melanoma (cancer), you can go here.
1 Lalueza-Fox C et al.
A Melanocortin 1 Receptor Allele Suggests Varying Pigmentation Among Neanderthals