“And Abraham journeyed from thence toward the south country, and dwelled between Kadesh and Shur, and sojourned in Gerar. And Abraham said of Sarah his wife, She is my sister: and Abimelech king of Gerar sent, and took Sarah.” - Genesis 20:1,2
When Abraham travelled to the land of Gerar. He, knowing the ungodly character of the people, told the people that his wife Sarah, was his sister. He did this because he knew that his wife was beautiful. Where people do not have any qualms about taking people’s wives they could harm or kill him because of his wife. Just as he feared, Abimelech king of Gerar sent, and took Sarah. But God came to Abimelech in a dream by night, and warned him that the woman was someone’s wife, warning him to return the woman lest he dies. (Genesis 20:1-10)
It is instructive that Abimelech quickly complied with the command from God to return the wife of Abraham to him besides showering him with gifts in cash and in kind. While the high moral code of the people at that time in regard to adultery is in line with the law of God, we should bear in mind the fact that Isaac took steps as his reasoning could carry him, to avoid unnecessary danger, hence he introduced his wife as his sister.
The truth is that when people are given to doing the righteousness of God to the best of their abilities, God Almighty gives them the wisdom to know what to do in difficult situations and helps them out of difficulties by His grace. “The Lord knoweth how to deliver the godly out of temptations, and to reserve the unjust unto the day of judgment to be punished.” - 2 Peter 2:9.