38 8 Judah said to Onan, “Come in to your brother’s wife; do a brother-in-law’s duty and raise up seed for your brother.” 9 Onan knew the seed would not be his so when he came in to his brother’s wife he wasted his semen on the ground, so as to not provide seed for his brother. 10 What he did was evil in the eyes of YHWH and YHWH put him to death, too.
11 Judah said to Tamar, his daughter-in-law, “Stay as a widow in your father’s house until Shelah, my son, has grown up.” He thought Shelah would die as well, like his brothers. So Tamar went and stayed in her father’s house.
Whatever it was that displeased YHWH about Er, his death led to additional displeasure. If this is simply a pattern of changing second-born to first-born status, it didn’t take the nature of second-borns into account. They are not all striving to be first.
Onan was not pleased to be told he was to enter his brother’s wife, in his stead. Readers are not told if Onan was resistant to his tribal obligation to multiply or if it had something to do with his relationship with his brother. It is also unknown if Onan had something against Tamar and desired to remove her status and security that would be enhanced with a son.
Whatever led Onan to resist this cultural task of being a sexual proxy, his strategy was to enter Tamar but leave before leaving a child behind. Today we would call that coitus interuptus. In ancient days, Rashi described it as “threshing within, winnowing without.”
Whatever Er had done to displease YHWH, this decision by Onan also displeased YHWH. Result: YHWH causes Onan to die.
With Brother One dead and Brother Two dead, Judah sees a pattern and acts to protect Brother Three, his youngest and, now, only son. Putting one and two together, Judah proceeds to protect Shelah from the Black Widow, Tamar.
Judah forces Tamar into a form of disgrace by sending her back to her father’s household. It didn’t aid Tamar to have Judah explain that she was only going back home until Shelah, son three, was old enough to serve as proxy for both Er and Onan. It didn’t take much to figure out Judah was never going to send for Tamar. Judah was not going to put Shelah in what seemed to him to be direct danger.
This interlude is to reveal a comparison between the leadership of Joseph and that of Judah. Focusing on Onan is a side trail. Judah and Tamar will continue to be the main storyline.