וַיְהִ֗י עֵ֚ר בְּכ֣וֹר יְהוּדָ֔ה רַ֖ע בְּעֵינֵ֣י יְהוָ֑ה וַיְמִתֵ֖הוּ יְהוָֽה׃
И Э, Иуда'первенец был нечестив в глазах Господа; и умертвил его Господь.
Rashi
רע בעיני ה' 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).
Chizkuni
וימיתהו, “He killed him.” The sin was that he did not sleep with his wife in such a way that she could become pregnant with his semen. Tamar had remained a virgin even after having been married to Onan, so that Yehudah was not guilty of sleeping with a close relative whose previous marriage had been consummated, so that she would have been forbidden to him on that score. Our author, at this point raises the same question this Editor had raised at the end of 38,1, i.e. that they should not have been culpable until the age of 20.
Ramban
AND ER, JUDAH’s FIRSTBORN, WAS WICKED IN THE SIGHT OF THE ETERNAL. Scripture does not specify the nature of his wickedness as it did in the case of his brother.148Verse 9 here. Instead, it simply states that he died for his own sin. It informs us that this was not by way of punishment of Judah for his role in the sale of Joseph, since the saving of Joseph’s life by Judah compensated for his role in the sale. There was no case of death of a child in the house of the patriarchs except this one who was wicked in the sight of the Eternal, since the race of the righteous is blessed. This is why Jacob mourned many days for his son Joseph, and he refused to comfort himself,149Above, 37:34-35. for he considered this to be a great punishment to himself, quite apart from his love for him.