So chapter 20 opens with Harry coming downstairs to find Hermione and Ginny already at breakfast... Oh wait, wrong book.
Here in Genesis, we see essentially a replay of the story in chapter 12. Abraham enters a strange new area, he figures the men of that area have no scruples and will kill him to take his wife, so he tells her to (half) lie and say that she's his sister, and troubles follow.
This time, there are a few differences, though. God actually talks directly to Abimelech in a dream instead of sending some plagues as He did in Egypt. Now, while God does say to Abimelech "Behold, thou art but a dead man..." and it sounds like a death threat, some have suggested (and I think it makes sense both logically and in regards to some of what follows) that the actual implication is that God has rendered Abimelech impotent. Either he's a "dead man" in bed, or he's a "dead man" because he is unable to have children, perhaps a bit of both.
Abimelech pleads with God, and points out that he's acted in good faith, and that in any case, he hasn't actually touched Sarah yet. Note that the only thing in the chapter that indicates that God caused any harm to anyone outside of the king's household is the word "nation" in verse four. While it may indeed imply that the curse/threat/plague/whatever was on the whole country, it seems also quite likely that being the king, Abimelech is referring to himself as a "nation", not an uncommon thing to do in a monarchy. Also of note is the similarity between this verse and verse 18:23. Although it's not crystal clear, it seems that Abimelech, despite Abraham's suspicions, is to some degree familiar with Abraham's God.
An interesting thing that comes out of this is that while God surely would have had the ability to just make everything right again if Sarah just went back to her husband, He decides to make Abimelech have to pay Abraham and Sarah, and ask Abraham to pray for him. I've got to say I think it's a little odd to be forced give gifts to a guy that nearly got you killed, but I think the real point is to respect Abraham as God's representative, albeit a very flawed one.
Yes, Sarah and Abraham were half-siblings. Is incest okay? No, but... As I think I mentioned before, there's some sort of dividing line in history that happens, and the reason for it is never given, but one could guess. Cain probably married his sister, or at the very least married a niece that was the daughter of two of his siblings. He essentially had no choice, did he? I think also, in the early days after the flood (which would be Abraham's time), there was a limited number of available women to men wanting to marry, and they probably would have to marry a close relative, perhaps even especially after Babel, when a non-relative wouldn't speak the same language. However, once your nation becomes as big as six hundred thousand men (and probably about the same number of women), you should be able to find a wife that's at least as distant as a second cousin. The dividing line for the Jews was the Exodus, and the handing down of the Law. In Leviticus 18, God says this practice should be no more.
So Abimelech gives all sorts of stuff to Abraham, along with some money to Sarah, and tells them they can live wherever they want in the land. Abraham prays and the people in Abimelech's household get to have children again, "For the LORD had fast closed up all the wombs..." Yeah, like the SAB said before, it's always the women with the problem in the Bible, isn't it?