The legend of marriage of Shiva and Shakti is one the most important legends related to the festival of Mahashivaratri. The story tells us how Lord Shiva got married a second time to Shakti, his divine consort. According to legend of Shiva and Shakti, the day Lord Shiva got married to Parvati is celebrated as Shivaratri - the Night of Lord Shiva.
Legend goes that once Lord Shiva and his wife Sati or Shakti were returning from sage Agastya’s ashram after listening to Ram Katha or story of Ram. On their way through a forest, Shiva saw Lord Rama searching for his wife Sita who had been kidnapped by Ravana, the King of Lanka. Lord Shiva bowed his head in reverence to Lord Rama. Sati was surprised by Lord Shiva’s behavior and inquired why he was paying obeisance to a mere mortal. Shiva informed Sati that Rama was an incarnation of Lord Vishnu. Sati, however, was not satisfied with the reply and Lord asked her to go and verify the truth for herself.
Using her power to change forms, Sati took the form of Sita appeared before Rama. Lord Rama immediately recognized the true identity of the Goddess and asked, "Devi, why are you alone, where′s Shiva?" At this, Sati realized the truth about Lord Ram. But, Sita was like a mother to Lord Shiva and since Sati took the form of Sita her status had changed. From that time, Shiva detached himself from her as a wife. Sati was sad with the change of attitude of Lord Shiva but she stayed on at Mount Kailash, the abode of Lord Shiva.
Later, Sati’s father Daksha organised a yagna, but did not invite Sati or Shiva as he had an altercation with Shiva in the court of Brahma. But, Sati who wanted to attend the Yagna, went even though Lord Shiva did not appreciate the idea. To hre great anguish, Daksha ignored her presence and did not even offer Prasad for Shiva. Sati felt humiliated and was struck with profound grief. She jumped into the yagna fire and immolated herself.
Lord Shiva became extremely furious when he heard the news of Sati’s immolation. Carrying the body of Sati, Shiva began to perform Rudra Tandava or the dance of destruction and wiped out the kingdom of Daksha. Everybody was terrified as Shiva’s Tandava had the power to destroy the entire universe. In order to calm Lord Shiva, Vishnu severed Sati′s body into 12 pieces and threw them on earth. It is said that wherever the pieces of Shakti’s body fell, there emerged a Shakti Peetha, including the Kamaroopa Kamakhya in Assam and the Vindhyavasini in UP.
Lord Siva was now alone undertook rigorous penance and retired to the Himalayas. Sati took a re-birth as Parvati in the family of God Himalaya. She performed penance to break Shiva’s meditation and win his attention. It is said that Parvati, who found it hard to break Shiva’s meditation seeked help of Kamadeva - the God of Love and Passion. Kaamadeva asked Parvati to dance in front of Shiva. When Parvati danced, Kaamadeva shot his arrow of passion at Shiva breaking his penance. Shiva became extremely infuriated and opening his third eye that reduced Kaamadeva to ashes. It was only after Kamadeva’s wife Rati’s pleading that Lord Shiva agreed to revive Kaamadeva.
Later, Parvati undertook severe penance to win over Shiva. Through her devotion and persuasion by sages devas, Parvati, also known as Uma, was finally able to lure Shiva into marriage and away from asceticism. Their marriage was solemnized a day before Amavasya in the month of Phalgun. This day of union of God Shiva and Parvati is celebrated as Mahashivratri every year.
According to another version of the legend, Goddess Parvati performed tapas and prayers on the auspicious moonless night of Shivaratri to ward off any evil that may befall her husband. Since then, womenfolk began the custom of praying for the well being of their husbands and sons on Shivaratri day. Unmarried women pray for a husband like Shiva, who is considered to be the ideal husband.