Why did Sarai & Abram have the Egyptian slave/servant girl (שִׁפְחָ֥ה) Hagar?
The presence of Hagar in the household of Abraham and Sarah is evidently a matter of the Providence of God as we see unfold the figure that she represents, that of bondage under a legal covenant.
The Hebrew word hamah is translated handmaid, maid-servant or bond-woman and refers to one 'in service' as the traditional expression has it.
Paul makes clear the spiritual allusion in Galatians 4:24,25 referring both to Mount Sinai and to Hagar herself and to Jerusalem which 'now is' and is in bondage with her children.
Which things are an allegory: for these are the two covenants; the one from the mount Sinai, which gendereth to bondage, which is Agar. For this Agar is mount Sinai in Arabia, and answereth to Jerusalem which now is, and is in bondage with her children. [Galatians 4:24,25 KJV]
Paul says that 'he that was born after the flesh' (that is to say Ishmael) persecuted him that was born after the Spirit' that is to say Isaac, who was born, in a figure, after the Spirit, he being born of one 'as good as dead' and of one who had 'ceased' after the manner of women, thus his birth being impossible by nature but granted in supernatural providence to establish a figure and to express spiritual truth.
Upon the persecution of her son, Isaac, Sarah requires that the bondwomen should be 'cast out' which perplexes Abraham until God instructs him to do as Sarah desires.
But God intended no harm to either woman or child and both were sustained, angelically, for the angel of the Lord had already promised to 'multiply her seed exceedingly' when she had, previously, run away from Sarah's harsh treatment, no doubt due to Sarah's jealousy of her fruitfulness against her own barenness.
These lessons are hard to learn, and relationships suffer as jealousy, impatience and one's own lack of fruitfulness cause upset. (I speak of spiritual relationships within the body of Christ.)
So neither Hagar nor Ishmael were in any danger, as they left Abraham's household for the promise of the angel and the ear of God were with her. 'And God was with the lad.'
These things transpired so that a figure might be set forth of bondage, and of freedom of spirit : of legal fruitlessness and of fruit by faith. Of Sinai's curse and Zion's blessing.
These things are set forth for our learning as Paul makes clear in his epistle to the Galatians.
Why did Sarai and Abram have the slave Hagar?
Slavery in biblical times was quite common. Yet the idea of having slaves had a somewhat different place in society amongst the Patriarchs.
Many of the patriarchs portrayed in the Bible were from the upper echelons of society and the owners of slaves and enslaved those in debt to them, bought their fellow citizens' daughters as concubines, and perpetually enslaved foreign men to work on their fields. Masters were men, and it is not evident that women were able to own slaves until the Elephantine papyri in the 400s BC. Other than these instances, it is unclear whether or not state-instituted slavery was an accepted practice.
It was necessary for those who owned slaves, especially in large numbers, to be wealthy because the masters had to pay taxes for Jewish and non-Jewish slaves because they were considered part of the family unit. The slaves were seen as an important part of the family's reputation. -The Bible and Slavery
As to why did Sarai and Abram have the slave Hagar? It can be thought that she was a gift from the Pharaoh of Egypt.
Genesis 12: Abram in Egypt
10 Now there was a famine in the land, and Abram went down to Egypt to live there for a while because the famine was severe. 11 As he was about to enter Egypt, he said to his wife Sarai, “I know what a beautiful woman you are. 12 When the Egyptians see you, they will say, ‘This is his wife.’ Then they will kill me but will let you live. 13 Say you are my sister, so that I will be treated well for your sake and my life will be spared because of you.”
14 When Abram came to Egypt, the Egyptians saw that Sarai was a very beautiful woman. 15 And when Pharaoh’s officials saw her, they praised her to Pharaoh, and she was taken into his palace. 16 He treated Abram well for her sake, and Abram acquired sheep and cattle, male and female donkeys, male and female servants, and camels.
17 But the Lord inflicted serious diseases on Pharaoh and his household because of Abram’s wife Sarai. 18 So Pharaoh summoned Abram. “What have you done to me?” he said. “Why didn’t you tell me she was your wife? 19 Why did you say, ‘She is my sister,’ so that I took her to be my wife? Now then, here is your wife. Take her and go!” 20 Then Pharaoh gave orders about Abram to his men, and they sent him on his way, with his wife and everything he had. - Genesis 12:10-20
It seems strange to us. But it was an accepted practice at the time to give servants and slaves as part of the dowry of a wealthy young woman.
If Hagar was a gift from Pharaoh, she was probably an accomplished servant with valuable skills. Becoming the servant of a nomadic tribeswoman may have been a step down socially for her.
It seems that Hagar’s new owner Sarah could not conceive a child, which was after all the primary function of a tribal leader’s wife. In her own eyes and in the estimation of the tribe she was a failure, and her barren state was a constant torment.
She decided to offer her slave Hagar to Abraham as a surrogate. Hagar would bear the child and look after it, but it would belong to Sarah and be accepted as the child of Sarah and Abraham.
To modern people, the idea of giving another woman to your husband to bear a child seems strange and brutal, but in ancient Near Eastern family law the practice was common and acceptable.
In this, we can see how Divine Providence was involved here when God changed his name to Abraham. Abraham means "a father of many nations". And a way for this to become a reality was for Abraham to be the father of Ishmael. Both Ish’mael and Isaac became fathers of great nations(Jews and Arabs). This is why Hagar became their slave in order to fulfill God’s word: Abraham would be the father of many nations. This was all foreseen by the Almighty.
The word "slave" doesn't have to mean what we think of it as today.
Many societies are very family oriented. When someone becomes aged or infirm, their family naturally supports and cares for them.
Unfortunately some people find themselves without any family to call their own. One option is to offer oneself as a servant to some other family. This can mean doing menial work, but it also means continuing support from the family when one can no longer work or care for oneself.
Even today, I know people from various parts of Asia that grew up with a family "servant" (and who are somewhat embarrassed to admit it). But it really isn't as bad as it sounds to Western ears.
One family I know quite well had a servant that acted as a nanny to the children, then when they were grown simply made breakfast and lunch and did minor housework. When I first met her in the 1980s, if I hadn't been told otherwise, I'd have thought she was the grandmother.
As she aged, she did less and less real work, and eventually moved to a retirement home, then nursing home, then … , all at the family's expense.
This kind of "slave" or "servant" is like what Hagar would have been; nothing at all like, for instance, American slavery 200 years ago.