Simple answer is to prevent the tongue from getting sunburned because they live in tropical and subtropical regions but the underside of tongues is a light pink color because it does not need as much protection.
A giraffe's tongue has melanin (same pigment that turns your skin dark when you get suntanned). Their dark tongues have more melanin, which protects them from getting sunburned.