All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Muslim historians differ on the exact number of the wives of the Prophet whom he brought into marital life. However, all Muslim historians agree that the Prophet married the following women: Khadeejah bint Khuwaylid, his children's mother who was his only wife until her death, 'Aa'ishah bint Abu Bakr As-Siddeeq, Sawdah bint Zam’ah, Hafsah bint ‘Umar ibn Al-Khattaab, Zaynab bint Khuzaymah, Umm Salamah Hind bint Abu Umayyah, Zaynab bint Jahsh, Juwairiyah bint Al-Haarith, Umm Habeebah Ramlah bint Abu Sufyaan, Safiyyah bint Huyayy and Maymoonah bint Al-Haarith all.
The maximum number of wives he had at one time was nine. As we mentioned earlier, the Prophet did not marry any woman during the life of Khadeejah . His wife Zaynab bint Khuzaymah died during his life. So the remaining nine were his wives when he died. The Prophet had more than four wives at the same time and this is one of the rulings that are peculiar to the Prophet who had the right to have more than four wives according to all the scholars of Islam.
Muslim scholars gave many reasons saying that there is great wisdom behind this that can be summarized in the following points:
First: acquiring knowledge and calling to Islam
There is no doubt that the wife is the closest person to her husband. She is the person who knows him the best and she is the most likely person to ask her husband about subjects that other people may be ashamed to ask in front of people. Thus, there is an underlying wisdom behind the numerous marriages of the Prophet so that his wives could report all the Prophet's, sallallaahu ‘alayhi wa sallam, deeds and sayings concerning the religion, ask the Prophet about very private issues and report his answers to the Ummah (Muslim nation). This actually happened and the books of the Sunnah (Prophetic tradition), have facts that support this.
Second: social wisdom
Six of the Prophet's wives were from the different subdivisions of the tribe of the Quraysh. These marriages drew these various tribal factions into family ties with him and, thus lessened enmity toward him.
Third: political wisdom that is closely linked to the social aspect
Indeed some of his wives were from leading noble families. These ties obligated these families to defend him and support him. In this stable political environment the Prophet had additional security to establish the religion.
Fourth: the numerous marriages showed the perfect behavior of the Prophet among his wives.
As Allaah The Almighty Says (what means): {And verily, you (O Muhammad) are on an exalted standard of character.} [Quran, 68:4].Indeed, the Prophet gathered these various wives from different tribes, backgrounds and varying age groups; one was a young virgin, others among them were widows with children, some were young or of middle-age, while others were old; some were previously married to rich men and others had been married to very poor men, etc. The Prophet was able to give to each one her rights and treat each in the way suited to her own state and situation with equity and justice. He was able to manage matrimonial life in a way that pleased each of his wives despite the great differences among them. His noble home was known to be very pleasant and stable while we can hardly manage successful matrimonial life with only one wife chosen after great scrutiny. No doubt, the Prophet, sallallaahu ‘alayhi wa sallam, is the perfect model for us in dealing with our wives regardless of their age or cultural and social background.
In summary, know that Allaah The Almighty gave the Prophet the dispensation of marrying more than four women. This actually occurred for some great wisdom and for lasting benefits. The claim that the Prophet was lustful and that he married numerous women because of sexual desire is untrue. In fact, the Prophet did not marry until he was twenty-five years old, and his first marriage was to Khadeejah a widow fifteen years his senior, and she remained his only wife until her death. All of his wives, except 'Aa'ishah were old widowed or divorced women. Thus, if his motive for multiple marriages was sexual desire he could have chosen young virgin girls.
Indeed, the Prophet used to advise the Companions to marry young virgin girls as he said to Jaabir ibn ‘Abdullaah who said, "The Prophet asked me: ‘Have you got married?’ I replied in the affirmative. He asked: ‘A virgin or a matron?’ I replied, ‘I married a matron.’ The Prophet said: ‘Why have you not married a virgin, so that you may play with her and she may play with you?’” The Prophet also said: "Marry the virgins as their mouths are sweeter, their wombs are cleaner and they get satisfied with the least." [Ibn Maajah] So, the Prophet knew very well where sexual desire is best satisfied, i.e. with virgins. But he gave greater importance to his mission and objectives which were much higher and more sublime.
As for your question on whether they lived in the same house. The answer is that each of them lived in a room especially for her and their rooms were adjacent to his mosque and none had an independent house just for herself.
Allaah Knows best.