Warning: Wikipedia contains spoilers
Malcolm Crowe (played by Bruce Willis), an award-winning child psychologist, is shot early on in the film by Vincent Gray, a former patient who accuses Crowe of failing to help him as a boy. Vincent then commits suicide, filling Crowe with guilt. After the shootings, Crowe and his wife grow increasingly distant from each other while he focuses on helping Cole Sear (played by Haley Joel Osment[?]), a boy who presents symptoms disturbingly similar to Vincent's.
Cole initially tells Crowe, "You're nice, but you can't help me." As the movie progresses, we see various scenes of people appearing in Cole's house after bedtime: A woman with cuts on her wrists screams, "No, dinner is not ready!" and "You can't hurt me any more!". A boy who invites Cole to see his father's gun turns away, whereupon we see that the back of his head has been shot off.
Who are these people? Cole eventually reveals his secret to Dr. Crowe: "I see dead people -- all the time." Crowe is incredulous and thinks Cole's mental condition is even more severe than he has earlier thought. However, he eventually comes to believe that the ghosts are real when he realises that he has tape recordings of Vincent hearing their cries in his old files. With Crowe's assistance and support, Cole learns how the dead people have come to him for help; he finishes their last tasks on earth, allowing them to finally move on.
At the end of the film it becomes clear that Crowe is himself a dead person, and has been since the shooting that began the story. But as Cole told him, "They don't know they're dead." Thus Crowe becomes the last person to be saved by Cole's aid, atoning for the sin of failing Vincent by helping Cole.