The ghost of the dead King Hamlet first appears in Act 1, and interestingly, he appears to a couple of minor characters first, but he won't communicate with them. It becomes clear to Horatio, that the ghost wants to speak to his son, Hamlet. When Hamlet actually confronts the ghost in scene 5, the ghost reveals why he is roaming the earth: he was not bitten by a snake as had been reported, but was actually poisoned by his brother, the new King Claudius, while he was sleeping in his garden. Hamlet is shocked by this news! The king then states his purpose: he wants Hamlet to avenge his death and "let not the royal bed of Denmark be / A couch for luxury and damned incest." The ghost-King wants Claudius off the throne, and he also expresses his disgust with the fact this his Queen, Gertrude, married her former brother-in-law. The ghost commands Hamlet to get revenge for these foul deeds, and his final words are "remember me." He wants Hamlet to remember his great father and to honor his memory by doing what he has commanded. It seems reasonable then that the ghost will not appear again as long as Hamlet does what has been asked of him. Once the "unfinished business" of this murder and incestuous marriage is over, then the ghost will be able to have his eternal rest.
The ghost doesn't appear again until late in Act 3. When he does, Hamlet is the middle of a huge, angry argument with his mother and Hamlet is trying to get his mother to see the error of her ways, but he has not yet done much in the way of taking care Claudius. Hamlet sees the ghost and immediately assumes that the ghost is there "come your tardy son to chide, / That, lapsed in time and passion, lets go by / The important acting of your dread command." Hamlet is partly right here. The ghost does not appear again, and eventually, Hamlet does fulfill the ghost's request.