Melanin makes the skin darker to protect it from the sun. Without enough melanin, the skin cannot protect itself, resulting in sunburn.