Vayikra18:30

וּשְׁמַרְתֶּם אֶת־מִשְׁמַרְתִּי לְבִלְתִּי עֲשׂוֹת מֵחֻקּוֹת הַתּוֹעֵבֹת אֲשֶׁר נַעֲשׂוּ לִפְנֵיכֶם וְלֹא תִטַּמְּאוּ בָּהֶם אֲנִי יְהוָה אֱלֹהֵיכֶם׃

So you shall keep My charge, not to do any of the abominable customs that were done before you, and not make yourselves impure with them. I am the Eternal your Almighty."

Vayikra 18:30

וּשְׁמַרְתֶּם אֶת־מִשְׁמַרְתִּי לְבִלְתִּי

Vayikra / Leviticus 18:30 · Drash

Vayikra 18:30

וּשְׁמַרְתֶּם אֶת־מִשְׁמַרְתִּי לְבִלְתִּי עֲשׂוֹת מֵחֻקּוֹת הַתּוֹעֵבֹת אֲשֶׁר נַעֲשׂוּ לִפְנֵיכֶם וְלֹא תִטַּמְּאוּ בָּהֶם אֲנִי יְהוָה אֱלֹהֵיכֶם׃

So you shall keep My charge, not to do any of the abominable customs that were done before you, and not make yourselves impure with them. I am the Eternal your Almighty."

Drash דְּרָשׁ

A fence for the Torah

One who has put a railing at the edge of the roof need not watch his feet every time.

The Mishnah: Moshe (Moses) received the Torah at Sinai, and it was handed on down to the Men of the Great Assembly, who said: "Make a fence for the Torah." Alshich: if you set fences around My bans, then even when you err you will break only the fence, not the ban itself. So the Eternal promises: "and you shall not become impure with them."

How Pirkei Avot and Torat Moshe explain it

Pirkei Avot Make a fence for the Torah

Moshe received the Torah at Sinai and handed it to Yehoshua (Joshua), Yehoshua to the elders, the elders to the prophets, and the prophets handed it to the Men of the Great Assembly. They said three things: be deliberate in judgement, raise up many students and make a fence for the Torah.

Torat Moshe So you shall keep My charge

He says: behold, I have said that you are promised that you will not do all these abominations. And if you keep My judgements and statutes, you will not do even part of them. And I add more: if you add, that is, besides My statutes and judgements you set a charge around My charge, fences and walls to keep what I commanded, so that you do not act after their deeds and customs, then I am sure of you that you will not do even part of the abominable customs. This is "keep My charge, not to do any of the abominable customs", and all the more so you will not do the abominations themselves. Or one may say it this way. The sages say that the Eternal commanded to set fences and walls, so that if a person errs, he errs in the fence and not in the ban itself. And this is the very language of the verse, where the Blessed One says: "Keep My charge", that is, set a charge around My charge. And what is this charge? These are the fences, "not to do any of the abominable customs": even if a person transgresses, it will not be an abominable custom, only a breach of the fence. And lest you say: who knows? For the evil inclination entices, perhaps it will make him break both this and that, and better one stumbling block than two. That is why it says: "and do not make yourselves impure with them, I am the Eternal": because you set a charge around My charge, I promise that you will not become impure with them, but most often will break only the fence, for I am the Eternal your Almighty. I am your Almighty, and "He guards the feet of His devoted ones" (Shmuel I / I Samuel 2:9). This is "and do not make yourselves impure with them, I am the Eternal your Almighty."

Takeaway

The Men of the Great Assembly (אַנְשֵׁי כְּנֶסֶת הַגְּדוֹלָה) were the sages of the time of the Second Temple, after the return from Babylon.
A fence (סְיָג) around the Torah is a ban of the sages that keeps a person at a distance from a ban of the Torah itself.