The god of the OT is portrayed as sometimes being uber-zealous about purity and other times giving a free pass to outrageous behavior from his believers - especially if they were of a certain high rank.
(He can kill Uzzah from touching the covenant ark in a critical situation, or kill Aaron's sons, Nadab and Abihu, for seemingly offering incense after consuming wine. All the while giving a free pass to David and Beth-Sheba, Loth and his daughters, Solomon and his harem, Judah and fornicating with his daughter-in-law, King Manasseh and his violence and idolatry, etc ...)
A perfect god wouldn't be inconsistent as YHWH is portrayed in the OT. Which shows that he is a product of the people who worshipped that deity. The stories committed to written form about the god of the hebrews are no less mythological than the greek or the babylonian stories about their gods. The only reason why that mythology crept into christianity was because Jesus of Nazareth, who was exalted to divinity status by his later followers, clearly endorsed the jewish mythology about their god. By extension, Christian believers since St. Paul and the early apostles scrambled to justify the actions of the god of the OT in an attempt to give his actions a purpose consistent with christianity.
That's all there is to it.