A harmful attribute on its own can be advantageous when combined with others. Think of it as finding a new "local maxima" in the sum total of evolutionary traits. Being (probably randomly) near-blind may have led to being slow and careful, which was the temperament needed to survive climbing trees, which got them away from ground-based predators and found them a lot of leaves ground sloths couldn't reach.
Evolution is basically a random-walk algorithm to find combinations that work.
They hide from predators like jaguars, ocelots and eagles, but why did no predator that grabs them from the trees evolve?
(Just trying to learn from them and their amazing ability to stay under the radar for 65 million years :D)