Lets treat you as if you are the 1st type of questioner tjat Bhforce describes. You genuinely want to know why. And not the 2nd type of questioner who wants to cast aspersions. So heres why:
Guru Ji had 3 wives because he had three rishtas. Guruji did not go looking for wives. In fact he did not even choose one. As you must know, panjabis have arranged marriages. So gurujis marriage was arranged 3 times. Why? People thought it was the highest honor if their daughter was married to the Guru. And as it was permissible in Indian, especially Kshatri traditions for men to have many wives, ppl thought it was ok and kept offering their daughters even tho guruji was married.You could say Guruji could refuse. But if he did, the girls married life was forfeit. A girl who was offered yet refused would not be asked to marry. So Guruji could change the system. He did. His first marriage was arranged by his father. Then Mata Sundris parents were admant that guruji accept their daughter. Guruji said I am already married. They said u r king of kings n kings have many wives. Also our daughter has been offered, if u refuse, her life will be ruined. She will be a burden to us. Noone will marry her and after we die, there is nobody to care for her. Please remember that back then women had no means of earning income. The fathers land and job belonged to son by law and there was no means for women to earn a living. So an unmarried women will have to depend on brothers charity or societys charity or starve. She will become a begger, destitute, a charity case. So guruji said Ok i will accept her, but no more. But some dared to go against gurus hukam and offer their daughter. Guruji reprimanded them and they said it was out of love and sharda. And that the daughter was offered already and if u reject her, she will be destitute. So guruji changed the system. He said I will not marry her. But she will not be destitute. I will clothe, feed and give her a home. Also I will give her the protection of my name. So in the future, no one can say guruji had 2 wives and a concubine. I hate to use this word. But stupid ppl who will cast aspersions must be answered. So guruji did marry her to give her legitamacy. But as Guruji announced, there will be no marital relations. Yes announced. That is why we know today why mata ji had no children. Otherwise doubters would.be saying it was infertility. Why did guruji announce it? To change the system. To indian minds that was a horrible fate. Like a sham marriage and it ensured the woman would be childless. And it was effective. No other rishta was ever offered again. Nobody wanted their daughter to suffer that. And it was a trial to mataji too, as we know because she asked guruji for a child. And the wonderous Guruji fulfilled her wish while keeping to his word by gifting the Khalsa as her child.
If you are a genuine questioner, you now know why guruji had 3 wives. If you are an aspersion caster/ doubter, u still will be unsatisfied.
I think guruji did the kindest and wisest thing.in all marriages. He didnt want to offer a childless sham marriage to mata sundri, as it was not her fault. But he had to for mata sahib deva to change the system and stop more rishte. He also tried to change woman roles and one.of his hukams is that of a woman earns or has an independent income, nobody has the right to take it from her. He also encouraged them to get skills. Like battle, scholarship, and learn self defense. He hired Mata Bhago Ji as his bodyguard. He supported Bibi Deep Kaur when she was shunned by her family for wrestling/fighting off muslims in hand to hand combat. Her family said she was soiled, unpure. Guruji said she is my daughter and Im proud of her.
As for Guru HarRai Ji, history isnt clear on the 8 wives. But the why is similar. They were sisters in need of protection. Most ppl in the olden days married widows of their brothers or young girls living with them to give protection of their name.