Misinterpretations often stem from projecting moral judgments onto Er and Onan's deaths mentioned here, such as viewing the verse as a divine commentary on their sins detailed in Genesis 38—Er's wickedness and Onan's refusal to fulfill levirate duty—or erroneously applying it to modern issues like contraception. In truth, this is a neutral genealogical list explaining which of Judah's sons joined the 70 descendants entering Egypt, with the deaths noted solely to account for their absence from the traveling company, not to reiterate or expound on the causes elsewhere in Scripture.
Genesis 46:12
King James Version (1769)
12 And the sons of Judah; Er, and Onan, and Shelah, and Pharez, and Zerah: but Er and Onan died in the land of Canaan. And the sons of Pharez were Hezron and Hamul.
This passage records the sons of Judah, a key figure in Jacob's family, as Er, Onan, Shelah, Pharez, and Zerah, noting that Er and Onan died in Canaan before the family's descent into Egypt. It serves as part of the detailed genealogy of Israel's ancestors entering Egypt during the famine, highlighting the surviving sons who continued Judah's line, which later became the prominent tribe from which King David and the Messiah would descend, underscoring themes of divine preservation of lineage amid loss and migration.