The Story of Shivaratri begins with the story of Shiva going into a deep state of penance and Sadhana after his loss of Sati. Sati is Reborn as Uma or Gauri or Parvati to Menaka and Parvat Raj. Write from a very young age she is attracted towards the worship of Shiva and contrary to what had happened in her last life time, in this lifetime she is supported by her parents in worshiping Lord Shiva.
Over the years have fascination for Lord Shiva becomes into an absolute directed energy when she can think of nothing else but Lord Shiva as her groom. She then takes the permission of a parents to go and serve Lord Shiva. It so happened that Parvat Raj takes her to Lord Shiva who is doing his Sadhana and prays to Shiva that that his daughter Parvati would assist him in his Sadhana. Shiva agrees. Also it had been predicted that a very cruel and tormenting Asura named Tarakasur could only be killed by a son of Shiva and Parvati. Having been tormented for so long, the Devtas are now very excited and impatient for a child born out of the union of Parvati and Shiva. So, Indra pushes Kamdev to go to Kailash and rain the couple with his arrows of Desire. In spite of trepidation Kamdev goes there and is assisted by his wife Rati Devi in creating a congenial environment. As soon as Shiva opens his eyes for a flip of a second Kamdev shoots is Arrow and Shiva for a milli second looks at Parvati. instantly he realises that he has been drawn towards the lady and understands the hand of Kamdev in it. He is highly angered and his third eye opens when he reduces Kamdev to and heap of Ashes.
And then he moves away from that place and goes into deep penance. Here Parvati is very upset and affronted and she too goes into a deep state of Sadhana. Therein she at one time only eats one leaf for months together. That is why she is also called as Aparna. One day when she thinks that there must have been some mistake or something lacking in her Sadhana that Shiva was not yet pleased so she plans to start it all over again, she finds and hermit coming her way stopping her and saying that she was extremely beautiful and she is not wait for Shiva to marry her. She could marry any person in the three worlds and that hermit was equally willing to marry her. Parvati gets exceedingly angry and on the verge of cursing the hermit, she ceases to find a laughing Shiva who tells her that he is enamoured by her Sadhana and by her devotion and would like to marry her.
The rest was all arranged by Narad Muni and Brahma ji.
Shivaratri is the night when Shiva got married to Shakti in form of Parvati and their Union brings about a potential of creativity in the Universe, not just the earth so it is celebrated across the planet as a festival.
That is why we are told to stay up all night so that the Shakti in the physical being can meet a higher goal or a higher purpose for our existence.