(ו) וַיִּקַּ֧ח יְהוּדָ֛ה אִשָּׁ֖ה לְעֵ֣ר בְּכוֹר֑וֹ וּשְׁמָ֖הּ תָּמָֽר׃ (ז) וַיְהִ֗י עֵ֚ר בְּכ֣וֹר יְהוּדָ֔ה רַ֖ע בְּעֵינֵ֣י יְהֹוָ֑ה וַיְמִתֵ֖הוּ יְהֹוָֽה׃ (ח) וַיֹּ֤אמֶר יְהוּדָה֙ לְאוֹנָ֔ן בֹּ֛א אֶל־אֵ֥שֶׁת אָחִ֖יךָ וְיַבֵּ֣ם אֹתָ֑הּ וְהָקֵ֥ם זֶ֖רַע לְאָחִֽיךָ׃ (ט) וַיֵּ֣דַע אוֹנָ֔ן כִּ֛י לֹּ֥א ל֖וֹ יִהְיֶ֣ה הַזָּ֑רַע וְהָיָ֞ה אִם־בָּ֨א אֶל־אֵ֤שֶׁת אָחִיו֙ וְשִׁחֵ֣ת אַ֔רְצָה לְבִלְתִּ֥י נְתׇן־זֶ֖רַע לְאָחִֽיו׃ (י) וַיֵּ֛רַע בְּעֵינֵ֥י יְהֹוָ֖ה אֲשֶׁ֣ר עָשָׂ֑ה וַיָּ֖מֶת גַּם־אֹתֽוֹ׃
(6) Judah got a wife for Er his first-born; her name was Tamar. (7) But Er, Judah’s first-born, was displeasing to the LORD, and the LORD took his life. (8) Then Judah said to Onan, “Join with your brother’s wife and do your duty by her as a brother-in-law, and provide offspring for your brother.” (9) But Onan, knowing that the seed would not count as his, let it go to waste whenever he joined with his brother’s wife, so as not to provide offspring for his brother. (10) What he did was displeasing to the LORD, and He took his life also.
What did Er do that made G-d angry enough to kill him?
רע בעיני ה' WAS WICKED IN THE EYES OF THE LORD — like the wickedness of Onan, and committing the same sin. This must have been the case because of Onan it is said, (v. 10) “And the Lord slew him also — Onan’s death was for a similar reason as Er’s death. Why did Er commit this sin? So that she should not bear children and her beauty thereby become impaired (Yevamot 34b).
Then Judah said to his daughter-in-law Tamar, “Stay as a widow in your father’s house until my son Shelah grows up”—for he thought, “He too might die like his brothers.” So Tamar went to live in her father’s house.
(ב) כי אמר כלומר היה דוחה אותה בקש שלא היה בדעתו להשיאה לו כי אמר פן ימות גם הוא כאחיו כי מוחזקת היא זו שימותו אנשיה לשון רש"י (רש"י על בראשית ל״ח:י״א) ולא ידעתי למה יתבייש יהודה המושל בדורו מן האשה הזאת ולא יאמר אליה לכי לשלום מביתי ולמה יטעה אותה והיא אסורה לשלה כמו שאמרו (יבמות סד) בנשואים בתרי זמני הויא חזקה
(2) FOR HE SAID, LEST HE ALSO DIE, LIKE HIS BRETHREN. That is to say, he dismissed her with a paltry reply because he never intended to give her to him in marriage. For he said, Lest he also die, like his brethren, for she has established herself as one whose husbands die young. This is Rashi’s Language.
Now I do not know why Judah, a ruler of his generation, should be shy towards this woman and not tell her, “Go in peace from my house,” and why should he mislead her when she is even forbidden to Shelah, just as the Rabbis have said concerning a married woman: “Twice establishes a presumption [that the woman is a katlanith — a woman whose husbands die].”
(ואמר) מר זוטרא בר טוביה אמר רב ואמרי לה אמר רב חנא בר ביזנא אמר ר"ש חסידא ואמרי לה א"ר יוחנן משום רשב"י נוח לו לאדם שיפיל עצמו לכבשן האש ואל ילבין פני חבירו ברבים מנ"ל מתמר דכתיב (בראשית לח, כה) היא מוצאת והיא שלחה אל חמיה
It is more comfortable for a person to cast himself into a fiery furnace, than to humiliate another in public to avoid being cast into the furnace. From where do we derive this? From Tamar, daughter-in-law of Judah. When she was taken out to be burned, she did not reveal that she was pregnant with Judah’s child. Rather, she left the decision to him, to avoid humiliating him in public, as it is written: “And Judah said: Bring her forth, and let her be burnt. When she was brought forth, she sent to her father-in-law, saying: I am pregnant by the man to whom these belong. And she said: Examine these, whose are these, the signet, and the cords, and the staff?” (Genesis 38:24–25).
אָמַר רַבִּי יוֹחָנָן אָמַר הַקָּדוֹשׁ בָּרוּךְ הוּא לִיהוּדָה אַתָּה אָמַרְתָּ (בראשית לז, לב): הַכֶּר נָא, חַיֶּיךָ שֶׁתָּמָר אוֹמֶרֶת לְךָ (בראשית לח, כה): הַכֶּר נָא. (בראשית לז, לג):
Rabbi Yochanan said that the Holy One of Blessing said to Yehuda, 'you said to your father 'do you recognize it?' I swear that Tamar will say about you, "do you recognize it?" (Gen. 38:25).
(א) כי אמר וגו'. כְּלוֹמַר, דּוֹחֶה הָיָה אוֹתָהּ בְּקַשׁ, שֶׁלֹּא הָיָה בְדַעְתּוֹ לְהַשִּׂיאָהּ לוֹ:
(1) ‘כי אמר וגו FOR HE SAID etc. — that is to say, he pushed her off with a straw (i.e., he put her off with a lame excuse) because he never intended to give her to him in marriage.

