Puranas contain many stories and legends describing the origin of this festival.
According to one, during the samudra manthan, a pot of poison emerged from the ocean. This terrified the Gods and demons as the poison was capable of destroying the entire world, and they ran to Shiva for help. To protect the world from its evil effects, Shiva drank the deathly poison but held it in his throat instead of swallowing it. This made his throat turn blue, and he was given the name Neelakantha, the blue-throated one.
Shivaratri is the celebration of this event by which Shiva saved the world.
According to another legend in the Shiva Purana, once the other two of the triads of Hindu Gods, Brahma and Vishnu, were fighting over who was the superior of the two. Horrified at the intensity of the battle, the other gods asked Shiva to intervene. To make them realize the futility of their fight, Shiva assumed the form of a huge column of fire in between Brahma and Vishnu. Awestruck by its magnitude, they decided to find one end each to establish supremacy over the other. Brahma assumed the form of a swan and went upwards and Vishnu as Varaha went into the earth. But light has no limit and though they searched for thousands of miles, neither could find the end. On his journey upwards, Brahma came across a Ketaki flower wafting down slowly. When asked where she had come from, the Ketaki replied that she had been placed at the top of the fiery column as an offering. Unable to find the uppermost limit, Brahma decided to end his search and take the flower as a witness.
At this, the angry Shiva revealed his true form. He punished Brahma for telling a lie, and cursed him that no one would ever pray to him. The Ketaki flower too was banned from being used as an offering for any worship, as she had testified falsely. Since it was on the 14th day in the dark half of the month of Phalguna that Shiva first manifested himself in the form of a Linga, the day is especially auspicious and is celebrated as Mahashivaratri. Worshipping Shiva on this day is believed to bestow one with happiness and prosperity.
A legend explains the all-night worship of Shiva on Shivratri. There was once a poor tribal man who was great devotee of Shiva. One day he went deep into the forest to collect firewood. However he lost his way and could not return home before nightfall. As darkness fell, he heard the growls of wild animals. Terrified, he climbed onto the nearest tree for shelter till day-break. Perched amongst the branches, he was afraid he would doze and fall off the tree. To stay awake, he decided to pluck a leaf at a time from the tree and drop it, while chanting the name of Shiva. At dawn, he realized that he had dropped a thousand leaves onto a Linga to keep himself awake, the tribal plucked one leaf at a time from the tree and dropped it below which he had not seen in the dark. The tree happened to be a wood apple or bel tree. This unwitting all-night worship pleased Shiva, by whose grace the tribal was rewarded with divine bliss. This story is also recited on Mahashivaratri by devotees on fast. After observing the all-night fast, devotees eat the Prasad offered to Shiva.
There is another possible reason for the origin of the all-night worship. Being a moonless night, people worshipped the god who wears the crescent moon as an adornment in his hair, Shiva. This was probably to ensure that the moon rose the next night.
Immediately after Mahashivaratri, almost like a miracle, the trees are full of flowers as if to announce that after winter, the fertility of the earth has been rejuvenated. And this perhaps is the reason why the Linga is worshipped throughout India as a symbol of fertility. The festivities differ in various parts of India. In southern Karnataka, for example, children are allowed to get into all kinds of mischief and asking for punishment is the rule of the day, probably originating from the mythological incident of Shiva punishing Brahma for lying.
TheVishvanatha Temple at Kashi inVaranasi celebrates the Linga (symbolic of the pillar of light) and the manifestation of Shiva as the light of supreme wisdom.
Mahashivaratri is thus not only a ritual but also a cosmic definition of the Hindu universe. It dispels ignorance, emanates the light of knowledge, makes one aware of the universe, ushers in the spring after the cold and dry winter, and invokes the supreme power to take cognizance of the beings that were created by him