Kaal Bhairav temple has a religious belief, based on an incident that happened between Lord Brahma, Lord Vishnu, and Lord Vishnu. Kaal Bhairav is one of the oldest temples of Lord Shiva.

Legend
One day, various great sages discussed who is the supreme lord of all. Lord Brahma and Lord Vishnu argue about their superiority. Lord Brahma proclaimed himself to be that superior person. On hearing this, Yagyeshwar (symbolic of Narayan) appeared and claimed that he is the supreme of all.
They decided to ask from four Vedas. To which rig Veda replied that the almighty who controls the working of the living being, named Rudra, is the supreme Lord. Yajur Veda replied, that the lord whom we worship through yagnas followed by other rituals, named shiva, is the supreme lord. Sam Veda replied to the lord who is worshipped by various respected yogis, none other than, Triambakam. At last, Atharva Veda replied, all human beings can see the Lord through Bhakti Marg and such a deity who can remove all the worries of human beings is the supreme and incomparable power, Shankar.
All four Vedas replied with the same answer, Lord Shiva. After watching all the happenings, Lord Shiva appeared, in a form of gleaming light in their midst. To which Lord Brahma stared angrily with his fifth head. Lord Shiva immediately created one living being and stated that he (the new being) will be the King of Kaal and will be known as Kaal Bhairav (death). He unknowingly plucked the fifth head of Brahma which was still burning with fury.
Lord shiva immediately ordered Kaal Bhairav to wander around the earth with the condition, that Brahma hatya dosh ( a menace to hurt a brahmin). Lord shiva created a being, a precarious lady, named Brahma hatya, who will follow him wherever he went.
Holding Brahma’s head in his hand, he started wandering around. That time he entered moksha puri, Varanasi and Brahma’s head (kapal) fell out of his hand on the ground. The place came to be known as Kapal Mochan followed by a teerth which, later came to be known as Kapal Mochan teeth. The moment Brahma’s head fell out of Bhairav’s head, gory women shouted, screamed, and left. Since then, she didn’t follow Bhairav.
Lord shiva stated that this form of Lord Shiva will forever be in Kashi to remove the sins of his devotees. Then onwards Kaal Bhairav stationed himself permanently in Kashi, giving shelter to all his devotees. People visiting Kashi always worships Kaal Bhairav, to get rid of any mishappening in their life.
Since then, it is believed that residents of Varanasi always worship Kaal Bhairav before starting any short trip, and worship after completing their trip, believing that Kaal Bhairav keeps an eye on his devotees. Special importance is given to Ashtami day (the eighth day after Poornima) in the month of Margashirsha for worshipping Kaal Bhairav. Besides, Sundays, Tuesdays, Ashtami, and Chaturdashi days are very important for worshipping Kaal Bhairav.
According to Kashi Khand, A person who circumambulates Lord Kaal Bhairav eight times will be absolved of all the sins committed by him. A devotee who worships Kaal Bhairav for six months will attain all types of Siddhi.