The Beis Hamikdash was surrounded by a series of walls. There were walls around the Azarah (courtyard) and there were walls around Har Habayis (the Temple Mount).
Walls create a protective barrier of defence to keep out any enemies or undesirable forces. But they also serve another function; Walls delineate how far the borders of a city extend.
The different areas within the Beis Hamikdash compound had differing degrees of holiness, reflected in what Avodah could be done in each area. These areas were delineated by borders in the form of the walls. The holiness of the inner space extended until the wall.
In Avodah we also need walls around our ‘holiness’. Our G-dly passion needs to be contained so that it does not manifest in the wrong place or the wrong way. Unrestricted, our inner spiritual intentions could result in the opposite of what we are trying to achieve. To share 2 couple of examples;
Before engaging in Avodah, a person should introspect on their spiritual standing so that feel a sense of humility before Hashem. Without ‘walls,’ the Yetzer Hara can hijack this introspection to bring a person to feeling of depression and melancholy. These feelings lead to a sense of inadequacy and apathy, where we feel incapable and unworthy of serving Hashem.
Another example is the condition described in Chassidus where a person’s fiery passion in davening and Avodah can lead to feelings of fiery anger and indignation towards others, once the davening is over. Without protective boundaries, the holy emotions can spill over into unholy manifestations.
We need limits to confine our holiness, ensuring that it is expressed only in a positive way and that it doesn’t express itself where it doesn't belong.
~ Based on Sefer Maamarim 5693 p508