What does Genesis 38:10 mean?
Onan had been forced by custom and his father's command to marry his brother's childless widow, Tamar (Genesis 38:1–8). This practice, known as a "levirate marriage," would later become part of the Mosaic law (Deuteronomy 25:5–6). Under this practice, any children born would be considered the heirs of the departed brother. This provided a legacy for the family and support for the widow. Even that later version allowed a man to refuse that role, though such a choice would have been considered dishonorable (Deuteronomy 25:7–10).In this case, Onan did not want to put his time and resources into children that would not be his own. Rather than refusing to marry Tamar, or declining to have intercourse with her, Onan tries to get the "best" of both options. He routinely has sex with Tamar but interrupts the act at the end to avoid conception (Genesis 38:9). In a very blatant sense, Onan is "using" Tamar. She's not being treated as a wife, or even as a childless widow, but as a sex object.
God saw Onan's repeated practice of this as a heinous sin and put him to death, just as He had done to Onan's brother, Er (Genesis 38:7). There's a poetic irony in the fact that Onan's sin is called "wicked," using a Hebrew word which is the reverse of the Hebrew name "Er."
With Onan's death, two of Judah's sons (Genesis 38:1–5) have been killed by God for their sinfulness. Both have died while married to Tamar. According to tradition, Judah's next son, Shelah, should now take Tamar. Out of fear (Genesis 38:11), Judah will delay that choice. His excuse is that Shelah is too young, but time will prove this to be a deceptive excuse (Genesis 38:14).