The moths that live on the two-toed sloths are coprophagous, which means that they consume poop. They lay eggs in the poop when the sloth comes to the ground, the larvae consume it, and after becoming adult moths, they fly to the trees to find sloths. In the fur, they lose their wings, mate and die. Fungi and bacteria in the fur break the moth's bodies down, and supply nitrogen to the algae that grow in the sloth's fur.
So why does the sloth care about the moths and algae that live on it? It's because sloths eat leaves that provide little nutrition, and with their small guts, they need to get more nutrients somehow. It turns out that they eat the algae! (Algae have been found in sloth's stomachs.) This means that technically, the sloths are farming the algae on their own bodies.
In another article, scientists have recently discovered that the fungus in sloth's fur may provide an important new drug for Chagas's Disease, which has been very difficult to treat. Also, if you want to see an adorable video of baby sloths being washed, it is embedded in the article!