While all humans have the same number of melanocytes (which produce melanin and determine skin color), those melanocytes produce different amounts of melanin. People who moved to northern climates needed more UV-B rays to make vitamin D so they produce less melanin. And over time that has gotten ingrained into the genome so northerners typically have less dark skin.
Within 1,000 years of a population's migration from one climate to another, descendants have the correct color skin to protect and maximize nutrients.
If you chart the evolution of skin color of populations living in one area for 500 years, the curve perfectly correlates UV radiation with skin color. The only exception are the Inuit, who have dark skin and hair even though they inhabit northern climates; that's because they eat lots of fatty fish, which provide vitamin D, so they don't need it from the sun. Our ancestors began migrating from northern Africa 250,000 years ago, so there has been lots of time for our skin types to adapt to our climate.
Find out more about this book:YOU: Being Beautiful: The Owner's Manual to Inner and Outer Beauty