This is one of those cases where the Bible shows God doing something that just seems to be uncharacteristic of Him.
Please check out Gen 12:10-20 in your favorite translation. Abram was going into Egypt due to famine. He told his beautiful wife to join him in a lie and say that they were brother and sister. Pharaoh, enchanted with her beauty and thinking she was unwed, brought her into his home and took her as a wife.
For this, Pharaoh's house was stricken with terrible diseases, while Abram's deception was rewarded with great wealth, which he was able to take with him once the Pharaoh got wise and expelled them.
What gives? Where is the God of justice? "All scripture is inspired by God and is useful for teaching, for reproof, for correction, and for training in righteousness," says Paul, according to 2 Timothy. But what kind of message is the Lord sending here?
(Ref also: Gen 20 and 26.)