What gives our skin its colour?

The foundation of any skin lightening or brightening product is the reduction of melanin in our skin. Does melanin play a photoprotective effect on our skin?