(כט) וַיָּ֤שׇׁב רְאוּבֵן֙ אֶל־הַבּ֔וֹר וְהִנֵּ֥ה אֵין־יוֹסֵ֖ף בַּבּ֑וֹר וַיִּקְרַ֖ע אֶת־בְּגָדָֽיו׃ (ל) וַיָּ֥שׇׁב אֶל־אֶחָ֖יו וַיֹּאמַ֑ר הַיֶּ֣לֶד אֵינֶ֔נּוּ וַאֲנִ֖י אָ֥נָה אֲנִי־בָֽא׃ (לא) וַיִּקְח֖וּ אֶת־כְּתֹ֣נֶת יוֹסֵ֑ף וַֽיִּשְׁחֲטוּ֙ שְׂעִ֣יר עִזִּ֔ים וַיִּטְבְּל֥וּ אֶת־הַכֻּתֹּ֖נֶת בַּדָּֽם׃ (לב) וַֽיְשַׁלְּח֞וּ אֶת־כְּתֹ֣נֶת הַפַּסִּ֗ים וַיָּבִ֙יאוּ֙ אֶל־אֲבִיהֶ֔ם וַיֹּאמְר֖וּ זֹ֣את מָצָ֑אנוּ הַכֶּר־נָ֗א הַכְּתֹ֧נֶת בִּנְךָ֛ הִ֖וא אִם־לֹֽא׃ (לג) וַיַּכִּירָ֤הּ וַיֹּ֙אמֶר֙ כְּתֹ֣נֶת בְּנִ֔י חַיָּ֥ה רָעָ֖ה אֲכָלָ֑תְהוּ טָרֹ֥ף טֹרַ֖ף יוֹסֵֽף׃ (לד) וַיִּקְרַ֤ע יַעֲקֹב֙ שִׂמְלֹתָ֔יו וַיָּ֥שֶׂם שַׂ֖ק בְּמׇתְנָ֑יו וַיִּתְאַבֵּ֥ל עַל־בְּנ֖וֹ יָמִ֥ים רַבִּֽים׃
וַיִּקְרַ֖ע אֶת־בְּגָדָֽיו, “he rent his outer garments.” When his father heard about Joseph’s apparent death, the Torah describes the rending of his garments with the words וַיִּקְרַ֤ע שִׂמְלֹתָ֔יו, “he rent his (under)garments.” When mourning parents or children, one rends all of one’s clothing, whereas when mourning siblings one only rends outer garments. The word שמלה appears as covering for one’s skin” (Exodus 22,26)
These pasukim are the first ones in the תנך that talk about ripping your clothes when a family member died. Although this is the first time, just some unknown midrashim learn the Halacha from this.
רב מנחם מנדל כשר זצ"ל (Chumash Torah Shalem) asks the question why the Gmara in Moed Katan doesn't learn from this pasuk.
There are two main reasons why the gemara doesn't learn it from this pasuk.
1.) It looks like it is a natural reaction for humans, as Reuven and Yaakov did it without getting told to by 'ה.
2.) It is a machloket (Talmud Yerushalmi Moed Katan Perek 3) if we are learning form things Am Israel did before Matan Torah.
From this we can learn that even though it isn't a Halacha it is very important to go with the natural instinct when it isn't against the Halacha.