The Lord had told the Israelites to abandon the detestable, defiling gods of Egypt because He was their God, but they rebelled against Him and refused to do so (cf. Exodus 5:19-21; Exodus 6:9; Leviticus 17:7; Leviticus 18:3; Leviticus 26:30; Deuteronomy 29:16-17; Joshua 24:14). He purposed to judge His people in Egypt for their rebellion, and their enslavement there was partially a judgment for their idolatry. Some expositors believed that this is a reference to God judging the Israelites at Mt. Sinai because of the Golden Calf incident. [1] However it seems clear that the Lord was referring to Israel"s idolatry in Egypt before the Exodus , which is not revealed as explicitly elsewhere in Scripture. Then He chose to bring them out of Egypt for the sake of His reputation among the other nations (cf. Genesis 15:13-16). [source][source][source]
"Though Israel had failed to sanctify the name of the Lord among the nations, the Lord himself would do so by his deliverance of Israel from Egypt [2]." [3][source]