If the purpose of the ghost could be summarized in one word, I would choose the word fulcrum. All of Hamlet's future turns on this one sighting of the apparition that urges him to avenge the alleged murder of his father. Had the vision not occurred, it is quite likely that Hamlet would have resisted the urgings of Claudius and returned to his studies. However, Hamlet is unsure of the apparition. Is it his father's ghost or a devil sent to deceive and trick him into murder? This indecisiveness continues to plague Hamlet throughout the play, raising the tensions of the play as Hamlet attempts to deal with his indecision. The issue of the ghost, by the way, is never resolved.
Enotes has some great material for further research.