Africans have black hair and skin.
Europeans have blond hair and white skin.
There are a lot of ultraviolet rays in the sun. Melanin can absorb ultraviolet rays to make vitamin D necessary for human body, but too much ultraviolet rays are harmful. In sunny places such as Africa, dark skin can protect the body, because melanin absorbs a lot of ultraviolet rays, so there won't be too much ultraviolet rays entering cells; In Scandinavia and other places with less sunshine, white skin color enables people to absorb enough ultraviolet rays to make vitamin D, so the difference of skin color is gradually formed in the long-term evolution of human adaptation to the environment.
The color of human skin is determined by four colors: white, yellow, black and red, which are matched in different proportions. The whitest people are in northern Europe, the blackest people are in West Africa, and the yellow people are in Southeast Asia. Sunlight can promote the production of melanin in the skin, so people living in tropical areas have more melanin and darker skin.