What did Yehudah mean when he declared "Tzadkah Mimeni"?
Rashi #2 (from Sotah, 10b): It was not he who stated "Mimeni", rather, Hashem, 3 who declared that Yehudah was not responsible for what happened. Rather, I, Hashem, arranged that he be intimate with Tamar. 4
Targum Yonasan: Both Yehudah and Hashem declared "Mimeni", as if it was written twice.
Ramban, Rashbam and Seforno: Yehudah acknowledged that Tamar was more righteous than he, inasmuch as, although Tamar tricked him into having relations with her, and he behaved correctly in sending her the kid-goat as promised, her action was more righteous than his, since she acted l'Shem Shamayim, 5 whereas he acted purely for selfish reasons (to retrieve his security - Seforno). 6
Makos, 23b: He meant that she was innocent and that he had erred in his judgment - since she had not committed Zenus with another man. 7
Ohr ha'Chayim: Her words are truer than mine, and she is more righteous than me. Shem's Beis Din decreed against Zenus with a Nochri. I admit that I had Bi'ah with her; she did not transgress the decree (she knew that she has Bi'ah with me). I did not know who she is; the Chazakah was that she is a Nochris, and I transgress the decree.
Ohr ha'Chayim: She did not do improperly. It was due to me (I caused her to despair from marrying Shelah).
Malbim: I did not give her to Shelah, because I decided to do Yibum myself. I was negligent for delaying; her trickery was justified.
Ha'Emek Davar: She intended for the Mitzvah of establishing seed for his brother; I did not intend for the Mitzvah.
Sotah, 10b: Yosef, who sanctified Hashem's Name in secret, when he refused the seduction of Potifera's wife, had one letter of Hashem's Name (Havayah) added to his name (Tehilim 81:6 - "bi'Yhosef Shemo"). Yehudah, who sanctified it in public through saying Tzadkah Mimeni, his name contained all the letters of Hashem's name.
And it was through Kidushin, and not through Z'nus - Da'as Zekenim and Hadar Zekenim.
Riva: If not for a Bas Kol, Yehudah could not have been sure that she was pregnant from him. Perhaps she had been Mezanah also with others!
Because, due to the combination of her modest behavior in her father-in-law's house (Refer to 38:15:2:2), and the prior decree that kings would descend from Yehudah, kings had to come out from both of them.
And, as Chazal have said (Nazir, 23b) 'An Aveirah that is performed l'Shem Shamayim is greater than a Mitzvah than is performed not l'Shem Shamayim'.
The Ramban and the Rashbam explain that, whereas she adhered to his instructions of waiting for Shelah to grow up, he did not adhere to his promise to give her to him when he did.
And he knew this because, on the one hand, he had certainly been intimate with her, whilst on the other, we do not suspect something that we do not know..
What does the Torah mean when it writes "v'Lo Yasaf Od Ledatah"?
Rashi #2 and Ramban #2: He did not cease having relations with her. 3
Ha'Emek Davar: 'Yedi'ah' regarding Bi'ah is always with intent for the woman. Even though his first Bi'ah was for Zenus, since it was [like Yibum] to establish seed for the Mes, it acquired even without intent. According to the opinion that Yakov never had Bi'ah with Rachel in Eretz Yisrael (she was pregnant with Binyamin before he returned), also Yehudah did not have Bi'ah with his daughter-in-law again; only the first Bi'ah was permitted to establish seed for the Mes. 4 The one who said that since Yakov married Rachel b'Heter [in Chutz la'Aretz], he was permitted even in Eretz Yisrael, like Yehudah was allowed to keep Tamar.
Rashbam: Otherwise, the Torah ought to have written 'v'Lo Yasaf Od mi'Ledatah'.
Ramban. Even though she was Halachically permitted to him - See Ramban. Oznayim la'Torah: Seeing as she was his daughter-in-law and it was only through Hashem's intervention that he had caused her to become pregnant. See Oznayim la'Torah.
Rashi: As we find in connection with Eldad and Meidad - See Rashi, Bamidbar 11:25. These are actually two opinions in Sotah, 10b.
If a Lav without Kares forbids the Yevamah to the Yavam, the Torah permits only one Bi'ah (Yevamos 20b). Ha'Emek Davar implies that [before Matan Torah], the same applied to a daughter-in-law. (PF)
Now that Yehudah realized that she is pregnant from him, why is she exempt?
Moshav Zekenim, citing the Chasid: Shelah was physically similar to Yehudah. She thought that Yehudah would give his ring and Talis only to his son. (She intended for Yibum with Shelah. 1 )
Moshav Zekenim: In the days of Yehudah, there was no Isur for her to have Bi'ah with her father-in-law, only with a Nochri. 2
Refer to 38:24:3:6*.
He sentenced her for disgrace to himself (refer to 38:24:3:3). Now, he realized that she was more righteous than he (based on Ramban, Ha'Emek Davar).
She went to Pesach Einayim after they told her that her father-in-law is coming! This requires investigation (PF).
Hadar Zekenim: Shem's Beis Din forbade a Nochri to have Bi'ah with a Bas Yisrael. They did not forbid Zenus of Bnei Yisrael.
Da'as Zekenim: If there were no brothers, the closest relative would do Yibum. Since I (Yehudah) did not want my son to do Yibum, it was upon me to do Yibum. Hadar Zekenim calls this 'difficult'.
Why does it say "Al Ken"?
Ha'Emek Davar: The custom was not to have Bi'ah with one's daughter-in-law even before Matan Torah. One could not know if Tamar intended for the Mitzvah to establish seed for the Mes, or for Zenus. It is astounding - why did I not give her to Shelah? It must be she intended to establish seed for the Mes, and therefore I did not give her to my son. I.e. she prayed to have seed from me, and Hashem caused that I not give her to Shelah, for he is a Kena'anis' son, and I am more important; I am Leah's son.