Nearly Headless Nick is the Gryffindor ghost. In spite of the fact that he's been dead five hundred years, he's still a fairly petty guy. He applies to join the Headless Hunt, a team of ghostly hunters on horseback who hurl their heads around. His application is rejected, though, because he is Nearly Headless – his head is still attached to his neck be a thin line of tissue. Nick is depressed at this rejection, so he manages to convince Harry, Ron, and Hermione to join his deathday party (an anniversary of his death on October 31, 1492).
Nick wants Harry to tell the leader of the Headless Hunt that he finds Nick imposing and frightening. Harry does attend the deathday party and he tries to convince the Headless Hunt, but he has no luck. They all leave the party just in time to find Mrs. Norris stunned before anyone else does. Harry's absence from the Halloween Feast and presence at the scene of the crime is all it takes to start rumors that he is Heir of Slytherin, come to attack the school's Muggle-borns.
Nick has one more part to play in the Book 2 plot: He is half-stunned by the basilisk. How this works, we don't know, since Nick is a ghost. Obviously, he can't die again but the basilisk still makes him unable to move on his own. Fortunately, Hufflepuff student Justin Finch-Fletchley only caught a glimpse of the basilisk through Nick, which saved him from instant death. We never get a precise idea of how Madam Pomfrey restores Nick to his normal ghosthood. Does Mandrake Restorative Draught work on ghosts? It doesn't really matter. By the end of the book, he's restored to his normal, happy, semi-transparent, floating state.
(Click the infographic to download.)