Kshetrapalamurthi is the form of Lord Shiva, where he safeguards the temples. In many of the epics, it is described that Lord Shiva often takes the form of Kshetrapalamurti, as he is concerned about the temples belonging to all the Gods, where the devotees feel the presence of the God.
This sort of Belief has been originated from the Principles of Shaivism, where it is believed by Shaivites that Lord Shiva himself appears in the dark hours to protect the devotees giving up their own families to follow the Shaivism.
The people following the Shaivism become ascetics and lead a life which is well disciplined and dedicated towards Spirituality.
It is believed that if not Lord Shiva, one of the associates of Lord Shiva will take the job to safeguard the temples. It is evident for instance in Varanasi, where the holy temple of Lord Shiva is being safeguarded by Kalabhairava.
In many temples of Lord Shiva, there would be a separate place dedicated to Nagaraja, the God of Serpents. Nagaraja would be safeguarding all the temples of Lord Shiva, Goddess Parvati, Lord Ganesha and Lord Kartikeya.
Surprisingly, despite being the Lord for Nagaraja, Lord Shiva is the Safeguard for the temples of Nagaraja and Nandeeswara. This shows the grace of Lord Shiva towards his devotees. Lord Shiva is also the Kshetrapalamurti for the temples belonging to Lord Vishnu, who is said to be equivalent to Lord Shiva in terms of Supremacy and Divinity.
However, there are very few situations in the epics where Lord Shiva is being worshipped as Kshetrapalamurti.