The Netziv understands that "u'shmartem es chukosai" refers to the study of Torah. He writes that we see a chiddush from this pasuk (21:22): limud haTorah protects against the punishment of galus even if other sins are being committed. The gemara (Nedarim 81) writes that during the time of bayis rishon the Chachamim and Nevi’im could not figure out the cause of the churban, “al mah avdah ha’aretz,” until Hashem revealed that it was because they did not say birchas haTorah, i.e. (as the Ran explains) they did not learn lishma. Everyone asks what the gemara means, as we know that during the period of bayis rishon the most serious aveiros of arayos, murder, idolatry were all being violated. Surely the Chachamim and Nevi’im were not oblivious to reality?! Some explain that the gemara was after the root cause. A culture were terrible issurim are tolerated does not spring up out of nowhere. Were it not for the sin of ignoring Torah, these other aveiros would not have taken hold. The Netziv, however, explains the gemara differently, based on his yesod in this pasuk: even if all those aveiros were being committed, Klal Yisrael would still not have been sent into galus had they only remained committed to limud haTorah.
Another important Netziv on the next pasuk:
וְלֹא תֵלְכוּ בְּחֻקֹּת הַגּוֹי אֲשֶׁר אֲנִי מְשַׁלֵּחַ מִפְּנֵיכֶם כִּי אֶת כָּל אֵלֶּה עָשׂוּ וָאָקֻץ בָּם:
“Chukos hagoy,” explains the Netziv, means the laws that the non-Jews setup. In the secular world things considered immoral one day are championed as “rights” the next. Social mores and norms are always changing. The Torah warns that although “ain tzadik ba’aretz” who does not slip up at one point or another and do wrong, although we all at some point fall prey to temptation, that is not a license to change our moral compass. Doing wrong is bad but making a wrong into a legal “right” and codifying it, institutionalizing it, is far worse.