The Lord had commanded Abraham to go to the land of the Canaanites, and there promised to give land to his descendants. After crossing the land from north to south, wandering in the land of promise as in a strange country, dwelling in tents (Hebrews 11:8-9), Abraham continued moving toward the south to the Negev, a region subject to frequent droughts . It was the path for those going to Egypt.
There was famine in the land: for being a semi-arid region, crops were scarce, and the pastures were drying preventing animal feed.
Egypt, because of the Nile delta, had enough water to sustain agriculture and pastures for animals. So Abram went across to there, away from the land where God had commanded. In the Bible, Egypt symbolizes the world. Like Abraham, many believers are tempted by the attractions of the world, which seems to offer an enjoyable lifestyle and forget about the holiness necessary to those who belong to God.
The population of Egypt was still small at the time, and the arrival of Abram with his retinue of servants, herds and flocks would attract much attention. But his biggest concern was their own safety because his wife Sarai was very beautiful, although she was then 65 years old (she was still at the height of her beauty, since she lived 127 years), and he was afraid the Egyptians would kill him in order to get her.
To avoid this danger, he used a ruse, told Sarai to tell the Egyptians that she was only his sister (which was true, as she also was the daughter of Terah, but from a second wife - Genesis 20:12). So if they fell in love with her, they would treat well not only her, but also himself for being her brother.
This act of Abram appears to be very objectionable to us, because not only would he be deceiving the Egyptians by hiding the truth, but also seems to show a weakening of his faith.
What he predicted happened: the Pharaoh himself received Sarai in his house with the intention of making her his wife, and dealt well with Abraham who enriched himself very much there. It is likely that the situation of Sarai, separated from him and living with Pharaoh, would have brought great sorrow to Abram.
But the Lord intervened, punishing Pharaoh and his household with great plagues: we have no description of them, but they led to Pharaoh discovering that Sarai was not only sister but also the wife of Abram.
Pharaoh rebuked Abram for having eluded him, and drove him away with his wife and all his possessions.
9 So Abram journeyed, going on still toward the South.
10 Now there was a famine in the land, and Abram went down to Egypt to dwell there, for the famine was severe in the land.
11 And it came to pass, when he was close to entering Egypt, that he said to Sarai his wife, "Indeed I know that you are a woman of beautiful countenance.
12 Therefore it will happen, when the Egyptians see you, that they will say, 'This is his wife'; and they will kill me, but they will let you live.
13 Please say you are my sister, that it may be well with me for your sake, and that I may live because of you."
14 So it was, when Abram came into Egypt, that the Egyptians saw the woman, that she was very beautiful.
15 The princes of Pharaoh also saw her and commended her to Pharaoh. And the woman was taken to Pharaoh's house.
16 He treated Abram well for her sake. He had sheep, oxen, male donkeys, male and female servants, female donkeys, and camels.
17 But the LORD plagued Pharaoh and his house with great plagues because of Sarai, Abram's wife.
18 And Pharaoh called Abram and said, "What is this you have done to me? Why did you not tell me that she was your wife?
19 Why did you say, 'She is my sister'? I might have taken her as my wife. Now therefore, here is your wife; take her and go your way."
20 So Pharaoh commanded his men concerning him; and they sent him away, with his wife and all that he had.
Genesis chapter 12, verses 9 to 20