Morgiana marries Ali Baba’s son, who remains nameless in many accounts of the story, because Ali Baba is grateful to her. In the ancient middle eastern culture that Ali Baba takes place in, a way to show gratitude to someone was to offer one of your children for marriage. This was often a way that deals were sealed or peace was made.
There is a bit more to the story, though. Spoilers for anyone who hasn’t read the original story. The final act of the thieves to stop Ali Baba from showing more people their cave is for the leader to befriend Ali Baba’s son and show up to dinner. Morgiana recognizes him, puts on a sword show, and stabs him in the heart. Ali Baba is enraged at first, but upon hearing that he was there to kill him, he gives his son to Morgiana in marriage.