Abimelech was the king of Gerar in southern Canaan during the time Abraham lived there.
When Abraham moved into the area, he knew that someone might take an interest in his wife, Sarah—and he feared that he might be killed so that she could be taken. So Abraham told a half-truth (or rather, a partial lie) that Sarah was his sister. But he hid the fact that she was also his wife, and he told Sarah to tell people that he was her brother. So Abimelech took her with the intent to make her his wife.
But before Abimelech even touched her, the Lord warned him that Sarah was already married and that he must return her to Abraham—or die. So Abimelech sent Sarah back to Abraham right away and paid him a large sum to account for any guilt he had incurred by his actions. He also invited Abraham to live anywhere in his land.
Abraham lied about Sarah because he thought the people of Gerar did not fear God. Yet Abraham’s dishonesty and fear revealed his own lack of fear of God and his selfish concern for his own well-being. If Abraham had trusted God to watch over him and was truthful from the beginning, he would not have unnecessarily endangered Abimelech’s life and well-being.