This very popular Shivaratri legend from Puranas explains why people stay awake all night on Shivaratri. Besides, it also tells us why Lord Shiva is also known as Neelakantha.
Once Indra - the King of Gods, while riding on an elephant came across Durvasa Muni who offered him a special garland. Indra accepted the garland but put in on the trunk of the elephant. The elephant was irritated by the smell and it threw the garland on the floor. This enraged the sage as the garland was a dwelling of Sri (fortune) and was to be treated as prasada. Durvasa Muni cursed Indra and all devas to be bereft of all strength, energy, and fortune.
In battles that followed this incident, devas were defeated and asuras (demons) led by Bali gained control of the universe. Devas sought help from Lord Vishnu who advised them to treat asuras in a diplomatic manner. Devas formed an alliance with asuras to jointly churn the ocean for the nectar of immortality and to share it among them. Lord Vishu told Devas that we would arrange that they alone obtain the nectar.
The churning of the milk - ocean was an elaborate process. Mount Mandara was used as churning rod and Vasuki, the King of Serpents, became the churning rope. Lord Vishnu himself had to intercede in so many ways to aid the Devas. All kinds of herbs were cast into the ocean and many great beings and objects were produced from the ocean and were divided between asuras and gods. It is said that following things emerged from the Samudra Manthan
During the Sagar Manthan by the gods and demons, haalaa-hala, a pot of poison also came out of the ocean. This terrified the Gods and demons as the poison was so toxic that it effects would have wiped out the entire creation. On the advice of Lord Vishnu, Gods approached Lord Shiva for help and protection as only he could swallow it without being affected. On the request of gods and out of compassion for living beings, Lord Shiva drank the poison. However, Parvati - Lord Shiva’s consort pressed his neck so that the poison does not reach his stomach. Thus, it stayed in his throat neither going up nor going down and Shiva remained unharmed. The poison was so potent that it changed the color of Lord Mahadeva’s neck to blue. For this reason, Lord Shiva is also called Neelakantha (the blue-necked one) where ‘Neela’ means blue and ‘Kantha’ means neck or throat.
As part of the therapy, doctors advised gods to keep Lord Shiva awake during the night. Thus, Gods kept a vigil in contemplation of Lord Shiva. To amuse Shiva and to keep him awake, the gods took turn performing various dances and playing music. As the day broke out, Lord Shiva, pleased with their devotion blessed them all. Shivaratri is the celebration of this event by which Shiva saved the world. Since then, on this day and night - devotees fast, keep vigil, sing glories of Lord and meditate.
At last, Dhanvantari - the Divine Physician appeared with a pot of Amrita (nectar of immortality) in his skilful hands. Fierce fighting ensued between devas and asuras for the nectar. To protect the nectar from asuras, devas hid the pot of nectar at four places on the earth - Prayag (Allahabad), Haridwar, Ujjain and Nasik. At each of these places, a drop of the nectar spilled from the pot and since then, it is believed that these places acquired mystical power. Grand Kumbh Mela is celebrated at the four places after every 12 year for this reason.
Eventually, Lord Vishnu took the form of a beautiful woman, Mohini. While her beauty bewildered the asuras, Mohini seized the nectar and returned it to the Devas, who drank it immediately.