(ד) אֶת־מִשְׁפָּטַ֧י תַּעֲשׂ֛וּ וְאֶת־חֻקֹּתַ֥י תִּשְׁמְר֖וּ לָלֶ֣כֶת בָּהֶ֑ם אֲנִ֖י יְהוָ֥ה אֱלֹהֵיכֶֽם׃ (ה) וּשְׁמַרְתֶּ֤ם אֶת־חֻקֹּתַי֙ וְאֶת־מִשְׁפָּטַ֔י אֲשֶׁ֨ר יַעֲשֶׂ֥ה אֹתָ֛ם הָאָדָ֖ם וָחַ֣י בָּהֶ֑ם אֲנִ֖י יְהוָֽה׃ (ס)
Rashi
את משפטי תעשו: אֵלּוּ דְּבָרִים הָאֲמוּרִים בַּתּוֹרָה בְּמִשְׁפָּט, שֶׁאִלּוּ לֹא נֶאֶמְרוּ הָיוּ כְדַאי לְאָמְרָן:
ואת חקתי תשמרו. דְּבָרִים שֶׁהֵן גְּזֵרַת הַמֶּלֶךְ, שֶׁיֵּצֶר הָרַע מֵשִׁיב עֲלֵיהֶם לָמָּה לָנוּ לְשָׁמְרָן? וְאֻמּוֹת הָעוֹלָם מְשִׁיבִין עֲלֵיהֶם, כְּגוֹן אֲכִילַת חֲזִיר וּלְבִישַׁת שַׁעַטְנֵז וְטָהֳרַת מֵי חַטָּאת, לְכָךְ נֶאֱמַר אני ה', גָּזַרְתִּי עֲלֵיכֶם, אֵי אַתָּה רַשַּׁאי לִפָּטֵר (יומא ס"ז):
את משפטי תעשו YE SHALL DO MY JUDGMENTS — Matters prescribed in the Torah which are in conformity with the human feeling of justice such as one feels ought to be ordained if they had not been already ordained by the Torah.
ואת חקתי תשמרו AND KEEP MINE ORDINANCES — matters which are decrees of the King (promulgated without any reason being stated) against which the evil inclination raises objections: "Why should we observe them and against which also the nations of the world raise objections, as e. g., the prohibition of eating swine’s flesh, of wearing clothes of a mixture of wool and linen, the purgatory power of "water mingled with the ashes of the Red Heifer" (טהרת מי חטאת) — therefore it is stated: "I", the Lord, have enacted this for you — you are not at liberty to evade the obligation (Yoma 67b).
Rashi
וחי בהם. לָעוֹלָם הַבָּא, שֶׁאִם תֹּאמַר בָּעוֹלָם הַזֶּה וַהֲלֹא סוֹפוֹ הוּא מֵת (שם):
וחי בהם means, THAT HE SHALL LIVE THROUGH THEM in the world to come (eternal life). For if you say it means that he shall live in this world, is it not a fact that in the end he must die! (Sifra, Acharei Mot, Section 8 10; cf. also Targ. Onkelos)
עבודה זרה כ״ז ב:י
ומאי ה"ל למימר (ויקרא יח, ה) וחי בהם ולא שימות בהם
The Gemara asks: And what would ben Dama have said? What verse did he intend to cite as proof that it was permitted for him to be healed by a heretic? The verse: “You shall therefore keep My statutes, and My ordinances, which if a man do, he shall live by them”(Leviticus 18:5). This teaches that one should live by God’s mitzvot, and not that he should die by them.This verse serves as a source for the halakha that one may violate a prohibition in order to save a life.
משנה תורה, הלכות שבת ב׳:ג׳
כְּשֶׁעוֹשִׂים דְּבָרִים הָאֵלּוּ אֵין עוֹשִׂין אוֹתָן לֹא עַל יְדֵי נָכְרִים וְלֹא עַל יְדֵי קְטַנִּים וְלֹא עַל יְדֵי עֲבָדִים וְלֹא עַל יְדֵי נָשִׁים כְּדֵי שֶׁלֹּא תְּהֵא שַׁבָּת קַלָּה בְּעֵינֵיהֶם. אֶלָּא עַל יְדֵי גְּדוֹלֵי יִשְׂרָאֵל וְחַכְמֵיהֶם. וְאָסוּר לְהִתְמַהְמֵהַּ בְּחִלּוּל שַׁבָּת לְחוֹלֶה שֶׁיֵּשׁ בּוֹ סַכָּנָה שֶׁנֶּאֱמַר (ויקרא יח ה) "אֲשֶׁר יַעֲשֶׂה אוֹתָם הָאָדָם וָחַי בָּהֶם" וְלֹא שֶׁיָּמוּת בָּהֶם. הָא לָמַדְתָּ שֶׁאֵין מִשְׁפְּטֵי הַתּוֹרָה נְקָמָה בָּעוֹלָם אֶלָּא רַחֲמִים וְחֶסֶד וְשָׁלוֹם בָּעוֹלָם. וְאִלּוּ הָאֶפִּיקוֹרוֹסִים שֶׁאוֹמְרִים שֶׁזֶּה חִלּוּל שַׁבָּת וְאָסוּר עֲלֵיהֶן הַכָּתוּב אוֹמֵר (יחזקאל כ כה) "גַּם אֲנִי נָתַתִּי לָהֶם חֻקִּים לֹא טוֹבִים וּמִשְׁפָּטִים לֹא יִחְיוּ בָּהֶם":
Mishneh Torah, Sabbath 2:3
These things should not be performed by non-Jews, minors, servants or women, lest they consider the Sabbath a light matter; instead, scholars and sages of Israel are to carry them out. One must not put off the desecration of the Sabbath in treating a serious patient, as it is written: "If a man obeys them he shall live by them" (Leviticus 18:5), but he must not die by them. From this you may infer that the laws of the Torah are not meant to wreak vengeance upon the world, but to bestow on it mercy, kindliness, and peace. Concerning those non-believers who say that [administering such treatment] constitutes a violation of the Sabbath and is forbidden, one may apply the verse [Ezekiel 20:25]: "[As punishment,] I gave them harmful laws and judgments through which they cannot live."
Ramban


Rambam - Guide For The Perplexed: 3:27.
The general object of the Law is twofold: the well-being of the soul, and the well-being of the body...The well-being of the soul is promoted by correct opinions communicated to the people according to their capacity. The well-being of the body is established by a proper management of the relations in which we live one to another. This we can attain in two ways: first by removing all violence from our midst: that is to say, that we do not do every one as he pleases, desires, and is able to do; but every one of us does that which contributes towards the common welfare. Secondly, by teaching every one of us such good morals as must produce a good social state...The true Law, which as we said is one, and beside which there is no other Law, viz., the Law of our teacher Moses, has for its purpose to give us the twofold perfection. It aims first at the establishment of good mutual relations among men by removing injustice and creating the noblest feelings. In this way the people in every land are enabled to stay and continue in one condition, and every one can acquire his first perfection.