In earlier cultures, Arabs practiced polygamy which led to conflicts in determining the paternity of their children.
However, the Qur’an came to restore the dignity of women as human beings, their chastity, and the purity of human lineage. So, the following Qur’anic ayah was revealed:
{And if you fear that you will not deal justly with the orphan girls, then marry those that please you of [other] women, two or three or four. But if you fear that you will not be just, then [marry only] one or those your right hand possesses. That is more suitable that you may not incline [to injustice} (An-Nisa’ 4:3)
Allah the Almighty commanded that men should stop having more than four wives. As a result, the companions of the Prophet who had more than four wives divorced the extra wives in obedience to Allah's decree.
The wives of the Prophet were exempted from a decree in a later ayah of the Qur'an.:
{Not lawful to you, [O Muhammad], are [any additional] women after [this], nor [is it] for you to exchange them for [other] wives, even if their beauty were to please you, except what your right hand possesses. And ever is Allah, over all things, an Observer} (Al-Ahzab 33:52)
Allah exempted the Prophet's wives from the divorce because as prophet wife they couldnt remarry.
The Prophet was allowed to keep his wives. However, he could not have any other wives other than the original nine.
The Qur’an says:
{And it is not [conceivable or lawful] for you to harm the Messenger of Allah or to marry his wives after him, ever. Indeed, that would be in the sight of Allah an enormity [atrocity]} (Al-Ahzab 33:53
Polygamy was prevalent in all cultures before Islam. The Prophet had the most rigid restriction compared to other Muslims. He was not allowed to take any other wives, while other Muslims were permitted to marry up to four. Islam rationalized and restricted the practice of polygamy to preserve human relationships based on dignity and mutual respect.