Melanin makes the skin darker to protect it from the sun. Without enough melanin, the skin cannot protect itself, which leads to a sunburn.