The story behind this Viratham:
Bhrungi Rishi was a great devotee of Lord Shiva but one defect existed in the great seer. He never prayed to Amman and completely ignored Her! Even during the supplicate practice of Pradakshina(circumambulation),He ignored Divine Mother.
To teach a lesson to this Sage, both Shiva and Parvathy merged into one and appeared as Ardhanareeshwara before the Saint. The saint did not budge and assumed the form of a Bee!(bee is called Brhunga in Sanskrit and thus his name Bhrungi rishi) and then pierced the body of Ardhanareeshwara/i and tried to do circum-ambulate Shiva's side alone!
(Ambal is Bhraamari and the sage plays with Bee rupa! This is arrogance brought about by ignorance) Ego is dangerous and spiritual ego is the most dangerous they say!
When divine mother gets angry Shiva cannot do anything, so Divine mother withdrew Shakti from the "Bhruga" and when the rishi assumed his form back, he could hardly stand on his legs!, this despite intense and arduous tapas for Lord Shiva. Lord Shiva had to give him a stick to make him stand up!
Lord Shiva then pacified Shakti and then made the Rishi realize the folly of ignoring Divine Mother. Thus Shiva-shakthi Aiykyata was realised on this day (Deepavali day) by the Rishi and he performed the Kedara-gowri Vratha, Himself.
Adi Shankaracharya Bhagavadpada Story:
The Great Guru Shankaracharya once went to Kashmir, wanting to engage in debate the followers of the Goddess (Shakti), known as the 'Shaktas.' No sooner had he reached the place than he was rendered immobile by a severe bout of dysentery. So seriously was he affected, that unable to get up from his bed, he for the moment, lost the power to speak.
Soon after, a twelve-year-old girl came near him and whispered in his ears: "O Shankara, do you think you can negate the cult of Shakti?"
Feeling helpless, Shankaracharya said, "Devi, I have come here for this very purpose, but right now I feel devoid of any potency. When I gain enough power to speak, only then will I be able to do so. Without Shakti, I cannot do anything."
The charming girl replied thus: "O revered preceptor, when you yourself cannot move an inch without your Shakti, how will you refute its cult? O Wise One, know me to be Shiva's Shakti - The supreme power activating this world. Charged by my own energy, you want to negate me?"
His mind now at rest, Shankaracharya bowed to the goddess, and left Kashmir as soon as he recovered.)