וַיֵּ֛רַע בְּעֵינֵ֥י יְהוָ֖ה אֲשֶׁ֣ר עָשָׂ֑ה וַיָּ֖מֶת גַּם־אֹתֽוֹ׃
איז געװען שלעכט אין די אױגן פֿון גאָט װאָס ער האָט געטאָן, און ער האָט אים אױך געטײט.
Ibn Ezra
They also claim that the phrase when brothers dwell together denotes close relatives, but not actual brothers. They bring the case of Boaz [cf. Ruth 3: 9 ; Ruth 3: 13] as evidence. This is vacuous, however, because no mention is made there of the word yibbum [here translated as “acting as the husband’s brother” — Translator], only of “redemption” [cf. Leviticus 25: 25]. Besides, what, then, is the meaning of the word together ? That they live in the same country? In the same courtyard? That they are fond of each other? The Dissenters claim further that the Scriptural usage of the term act as her husband’s brother proves that she is his brother’s wife in name only, but not in fact, as in the phrase “your brother’s wife has returned” [Ruth 1: 16]. But they have stumbled into error. Note that regarding the sons of Y ǝ hudah, Scripture explicitly says, “act as her husband’s brother” [Genesis 38: 8], although there he clearly already was her husband’s brother. Even the abovementioned use of the word “your brother’s wife” can be understood on the grounds that the two women were married to two brothers. Every sensible person knows that, although the prohibitions that were told to Moshe were not forbidden beforehand, if someone before the time of Moshe refrained from engaging in such actions he would not have displeased God . Scripture even states, “for the men of the land who preceded you practiced all these abominations” [Leviticus 18: 27], and yet we have no evidence that any prophet had ever admonished them against such actions. With respect to Onan Scripture specifically says that he did not “provide progeny for his brother” [Genesis 38: 9] and consequently “it was evil in the sight of God ” [Genesis 38: 10]. For these reasons, we will rely on the tradition that actual brothers are meant here.
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).
Siftei Chakhamim
Strangulation. Because it is written “shall be... put to death” without specifying [which death penalty], and this [case here is] a death administered by man. And we also find “death” mentioned without specifying [which death penalty], regarding a death administered by heaven, by [the deaths of] Er and Onan where it is written (Bereishis 38:10), “And He also put him to death.” [Therefore, we say that] just as a [an unspecified] death administered by heaven leaves no mark, so too, the death administered by man is one that leaves no mark. See all this in Sanhedrin (52b).