Pedro II despised slavery. It's not his fault that much of Brazil's economy back then relied heavily on slavery. Abolishing it right away would have been an economic disaster for Brazil, so he decided in his wisdom to chip away at slavery bit by bit. And then slavery was abolished completely, and the slave owners and generals threw a hissy fit and decided that a coup was actually a good idea.
And Pedro II had many other achievements. He was a strong advocate for the freedom of speech and freedom of the press. He lead Brazil to victory in the Platine, Paraguayan, and Uruguayan Wars, won a diplomatic victory over Great Britain, established education reform, etc. He was friends with Louis Pasteur, Richard Wagner, and Henry Wadsworth Longfellow, and was highly respected by people such as Victor Hugo and Friederich Nietzsche. He could speak and read many different languages and said that if he wasn't the emperor, he would have wanted to become a teacher.
He truly was the greatest Brazilian to ever be born