Mark Ritchie, a professor of biology at Syracuse University, provides the following explanation:
HIPPOS spend most of their day resting in water and can hold their breath for up to 30 minutes.

Hippos secrete a reddish oily fluid sometimes called "blood sweat" from special glands in their skin. But the fluid is not sweat. Unlike sweat, which some mammals (including humans) secrete onto their skin, where it evaporates and therefore cools the body, this fluid functions as a skin moisturizer, water repellent and antibiotic. It appears red when exposed to full sunlight, which led the first European discoverers in Africa to call it "blood sweat."

Hippos mostly try to avoid direct sunlight by lying in water during the day and feeding at night. Their skin is very sensitive to both drying and sunburn, so the secretion acts like an automatic skin ointment. It also protects the skin from becoming waterlogged when a hippo is in the water. The detailed chemical composition of this secretion, which is unique to hippos, remains something of a mystery.