Asking from a non-muslim's viewpoint, If Islam preaches equality, then why does it permit slavery?
Even though our Imams and Prophets has accepted slave system, but Islam had a plan to free slaves gradually. What people don't normally pay attention to is that if a wrong system has entered a society, removing it needs time and scheduling. If you do something without considering all aspects, it'll have opposite results. It's like something infected with a dangerous virus, or an addicted person who cannot just stop using drugs all of a sudden.
Now if Islam had ordered to free slaves, some of them could got perished when they were an important group in the society. Or a large group of people could became jobless without a place to live in.
Islam consider freeing slaves an "Ibadat", all Prophets and Imam tended to free slaves so simply to give other people a lesson on how it's done.
The Prophet Muhammad (PBUH) said:
This is a quite popular Hadith among Shi'as.
Islam permits slavery for those who come to fight against muslims and Islam. Slavery is a kind of blessing for those who are slaves.
Islam does not permit slavery to muslims. In fact one of the requirements of being a muslim is to not enslave one another (3:64).
But Islam does not force other adherers to other ideology to conform to Islam's belief system (15:3,23:54,43:84,52:45,70:42) even at the expense of death to uphold their beliefs(6:112) at one extreme.
So if there is a citizen (a mushrik/polytheist or kaafir/rejecter of the concept of Prime Creator) amongst the nation and he has a slave who is a muslim, the nation has no right to take away from the citizen his muslim slave, because it's part of the belief of this citizen to own a slave, and the nation has no right to take it away from him. Otherwise there would be bloodshed amongst muslim and non-muslim to fight for an ideological point of view, which Islam does not want. This is what is meant in the verse 24:32.
that is amongst your male and female citizens that are being enslaved. If we take it that islam allows slavery amongst the muslims, it would be contradicting verse 3:64.
so in this verse Allah SWT is talking to us as a nation (with muslim and non-muslim citizens) and not as a group of muslims.