Q: Why do equatorial people have dark skin?
A: Because their parents gave them genes telling their bodies to make lots of pigment.
Ok, so why did their parents give them these genes?
Because that's what their parents had, and they just gave them copies.
So, why did their parents have those genes? Because their parents did.
Its called inheritance. Heritable traits. You look like your folks.
And they like theirs.
But over generations, the ones with the 'best' or 'optimal' amount of pigment did had more grandkids. Didn't get skin cancer as a kid and die. Didn't get skin cancer and have fewer kids. Just wasn't as sick, its that simple. (Ever had real sun exposure? It causes second degree burns (blistering) even in folks who tan gradually.)
Thousands of generations. Look at what selective breeding did to dogs. Nature does that to us, its called natural selection. Evolution. Filtering the libraries our parents give us.
So: why do white people make so little pigment?
Because their parents told them to :-)
But it was adaptive at their latitudes: because sunlight varies with latitude. So equatorials get lots of pigment to avoid cancer, but extra-tropicals lose the pigment so they get enough vitamin D. Optimal means different level of pigment in different latitudes, because of the geometry of the sun and latitude.
So its obvious: blacks and whites are optimal for their ancestral latitudes.
What does this mean now? It means blacks in the north are vitamin D deficient, their bodies 'expecting' more sun; and whites in the south are succeptible to skin cancer, their bodies expecting less sun.
There are other implications for body shape and proportion involving heat load, which differentiate equatorials and eskimos, but those are not dealt with in this essay.
BTW Tay sachs gives you an advantage if you have 1 copy (but not 2) and live where TB is common.
BTW sickle cell gives you an advantage if you have 1 copy (but not 2) and live where Malaria is common.
The first question listed here is a test of your understanding. The rest of the explanation is a description of how you might think about it. Enjoy.