Why was it that the Qur'an did not go to the extent of completely prohibiting slavery ?

Islam, which had undertaken a practical course of action necessary for the eradication of slavery, however, never went to the extent of issuing an order of total prohibition against it which it had done in the cases of intoxicants and adultery. Why was this so? 

There is more than one reason for this. The line of action of the Qur'an which refrained from completely prohibiting slavery has, in fact, made clear its applicability for all time. From the stand adopted by it in this issue we has been given to understand the fact that the Qur'an is, indeed, a revelation from the Lord God Himself who is bestaware of the changing trends and evolutionary processes of human society. If the Qur'an's act of not imposing total prohibition on slavery is studied in some depth, it will be a conclusive testimony to the statement of fact that Islam is, indeed, adaptable to the exigencies of time and that its recommendations are practical in any age.

The beginnings of the system of slavery traces itself to the prisoners who were captured in war. Before the proclamation made by modern states which imposed a total prohibition on slavery, it was the usual and prevalent practice to enslave prisoners captured in war. Prisoners-of-war were either to be killed or enslaved. This was the practice. Indeed, these were the only practical solutions available. After all, there was no provision to accommodate them as prisoners in those times.

What was to be done with those who were captured as prisoners-of-war? 

In this regard, the recommendation of the Qur'an is as follows: 'Therefore, when ye meet the unbelievers (in fight), smite at their necks; at length, when ye have thoroughly subdued them, bind (the captives) firmly: therefore (is the time for) either generosity or ransom: until the war lays down its burdens. Thus (are ye commanded): but if it had been Allah's Will, he could certainly have exacted retribution from them (Himself); but (He lets you fight) in order to test you, some with others. But those who are slain in the way of Allah, He will never let their deeds be lost.' (Qur'an 47:4). In this verse, which instructs to kill the enemies on the battle field, there is also the command to either ransom or set free those captured in war. In the light of this verse, all the eminent companions of the Prophet have opined that prisoners-of-war were not to be killed.

The Prophet has himself set the precedent in handling prisoners-of-war in four ways:
1. Set them free without any ransom. Prisoners-of-war may be set at liberty if it is clear that it will not be harmful for the Muslim society to do so.

2. They may be exchanged for the Muslims captured by the enemies.
3. They may be freed after securing a ransom.
4. They may be divided amongst the Muslims soldiers as slaves.
It may be seen that the Prophet had, in different battles, employed all the different types of options listed above. Amongst those four options, the last option of enslaving the prisoners-of-war was used only when the other three options were wholly impractical. Indeed, if slavery was totally prohibited, a situation would have come up wherein the Muslims would never be able to accept this option at all. In actual fact, therefore, such a situation would have created many a difficulty for the Muslims especially in a social context wherein such slavery prevails as an established institution.
Those who where engaged in warfare with the Muslim society were people who accepted slavery as an option and were warring to acquire slaves as well. Furthermore, when warring with them, they either enslaved or killed the Muslims captured by them. If slavery had been abolished, the Muslims would never have been able to enslave those captured from their side. This would then have enabled the enemies to perpetrate even greater cruelty towards the Muslim prisoners. The Muslims would, moreover, be unable to use the captured prisoners of the enemy to effectively engage in the negotiation forthe release of  those who were captured from their own side.
The enemies were aware that if slavery was abolished in Islam, the Muslims would become powerless to enslave or kill those captured from their side. Thus, the enemies would never settle for a mutual understanding that would allow for an exchange of their prisoners in return for the freedom of those captured from the Muslims.
As for the Muslims, the prisoners captured from the enemy ranks will merely end up being a headache. Their accommodation will become the responsibility of the Muslim community. It need not be said that on occasions where thousands of prisoners are captured, accommodating all of them will be an enormous task. The Muslim community will then become obliged to provide them with food and clothes as well. While they gladly live here under the protection of the Islamic community, those captured from the Muslim side will live suffering the cruelties inflicted upon them by the enemies of Islam and executing the heavy tasks imposed by them. This can never be just. Indeed, this can, only become the cause of the destruction of the Muslim community. A situation will then come up in which war can only serve to annihilate the Islamic community. Therefore, under a context in which slavery was not prohibited worldwide, it would have been suicidal if Islam had ventured to prohibit slavery. It was then for the same reason that Allah, the Knower of all Space-Time, refrained from prohibiting slavery.
In reality, because slavery existed in the world as an established institution, there was bound to be greater harm than good if Islam had abolished it. Islam, while allowing for slavery, did, however, teach that the slave and the master were brothers one to the other and that the slave had rights of his own and that he was to be treated humanely,  and that he was never to be insulted and humiliated. Thus, for a slave living under a Muslim, slavery would never be a burden. Furthermore, it is possible for him to become a free man at any point of time. He can attain his freedom  when he is inclined towards it.