תָּנוּ רַבָּנַן וְרָאִיתָ בַּשִּׁבְיָה בִּשְׁעַת שִׁבְיָהּ אֵשֶׁת וַאֲפִילּוּ אֵשֶׁת אִישׁ יְפַת תּוֹאַר לֹא דִּבְּרָה תּוֹרָה אֶלָּא כְּנֶגֶד יֵצֶר הָרָע. מוּטָב שֶׁיֹּאכְלוּ יִשְׂרָאֵל בְּשַׂר תְּמוּתוֹת שְׁחוּטוֹת וְאַל יֹאכְלוּ בְּשַׂר תְּמוּתוֹת נְבֵילוֹת [...]
The Gemara says on this (Kiddushin, 21b), “The Torah only speaks here according to the yetser hara [inclination to evil].” That the Torah permitted an outlet for the yetser hara is something that we find nowhere else (in the Torah). Yet there are times when we find that a man’s yetser hara overpowers him until he cannot move at all, and then it is clear that this state came from God, as we find with Yehuda. The Torah revealed this so that someone caught in this state would not become depressed.
כִּי תֵצֵא לַמִּלְחָמָה. שָׁנוּ רַבּוֹתֵינוּ, מִצְוָה גּוֹרֶרֶת מִצְוָה, וַעֲבֵרָה גּוֹרֶרֶת עֲבֵרָה. וְרָאִיתָ בַּשִּׁבְיָה וְגוֹ', וְגִלְּחָה אֶת רֹאשָׁהּ וְעָשְׂתָה אֶת צִפָּרְנֶיהָ, כְּדֵי שֶׁלֹּא תִּמְצָא חֵן בְּעֵינֶיךָ. מַה כְּתִיב בַּתְרֵיהּ, כִּי תִהְיֶיןָ לְאִישׁ שְׁתֵּי נָשִׁים וְגוֹ'. שְׁתַּיִם בַּבַּיִת, מְרִיבָה בַּבַּיִת. וְלֹא עוֹד, אַחַת אֲהוּבָה וְאַחַת שְׂנוּאָה, אוֹ שְׁתֵּיהֶן שְׂנוּאוֹת. מַה כְּתִיב אַחֲרָיו, כִּי יִהְיֶה לְאִישׁ בֵּן סוֹרֵר וּמוֹרֶה. כָּל מָאן דְּנָסִיב יְפַת תֹּאַר, נָפִיק מִנַיְיהוּ בֵּן סוֹרֵר וּמוֹרֶה [...] הֲרֵי לָמַדְנוּ, שֶׁמִּצְוָה גּוֹרֶרֶת מִצְוָה, וַעֲבֵרָה גּוֹרֶרֶת עֲבֵרָה. לְפִיכָךְ נִסְמְכוּ פָּרָשִׁיּוֹת אֵלּוּ זוֹ לָזוֹ.
Consider the order of these matters. First desire consumed the heart of the man to take a woman of the war captives for a wife, and surely it seemed to him that her actions were good, for we are not dealing with foolishness. Then afterwards he comes to hate her on sight, as her actions are not at all what he thought they were, and he hates her strongly and is disturbed, wondering where his initial desire to take her came from. So he consoles himself, saying, maybe a good son will be born from her. Then he sees that the son born to them is stubborn and rebellious, and they bring him to the court of law, and kill him. Then pain and mercy fill his heart over his executed son, for he was innocent, as it says in the Gemara (Sanhedrin, 72a), “He will be killed for eating over a tartemar (180 cc.) of meat and drinking over a half log (37 ml.) of wine.” He becomes increasingly disturbed from the series of events that passed over him. Therefore, the very next verse is “for he who incurred the death penalty … do not let the corpse of the hang overnight … for a hung corpse is a dishonor to God.” (Devarim, 21:23).
In this God is consoling his father’s conscience, telling him that surely there was something good in him, or else God would not be so careful as to not let him hang the body overnight. From this, it is apparent that he is not like an inanimate object, but rather, there was something good in him that required clarification. Thus, the desire of the father to take the mother was not in vain. Following after is the section dealing with returning a lost object. This shows how with God there is a fixing for everything, so that any desire and any action done among Israel would not be lost to irrecoverable exile, and everything happens with God’s involvement (hashgacha). That he took the mother was from the desire for the good in her, and his hate for his son was only for the evil in him, and his execution was not in vain for in this it becomes clear that he was innocent.