Melanin protects skin from the sun's ultraviolet rays. These can burn the skin and reduce its elasticity, leading to premature aging. People tan because sunlight causes the skin to produce more melanin and darken. Related Theory:- The basal cell layer contains cells called melanocytes. Melanocytes produce the skin pigment known as melanin, which gives skin its tan or brown colour.