Praise be to Allah.
Slavery in Islam was originally prescribed because of Kufr. If there is jihaad between the Muslims and the kuffaar, and a number of kuffaar are taken prisoner, the commander is given the choice of sharing them out, doing them a favour (by releasing them) or paying their ransom. If they are shared out as part of the booty, they become slaves, subject to the laws governing products which may be sold. But at the same time, Islam urges the freeing of slaves and makes doing so an act of expiation for numerous sins. In principle, slavery is not something that is desirable; what is encouraged in Islam is the freeing of slaves. If a woman is enslaved according to shareeah, it is permissible for her master to have intercourse with her. This is unlike prostitution or zinaa, which Islam has forbidden as a precaution against mixing lineages and other reasons for which it is forbidden. There is no comparison between the two, because if a slave woman becomes pregnant, the child belongs to the master and she becomes free when he dies, because she has become the mother of the masters child (umm walad), and is subject to the same rulings as a wife. And Allaah knows best.