Act 1, xcene 5 is the famous "Ghost Scene" in Hamlet, when the ghost of Hamlet's father, the former King of Denmark, appears to Hamlet to tell him the truth about his death (Hamlet's uncle, Claudius, did it!) and to implore Hamlet to swear that he'll avenge his death.
If thou didst ever thy dear father love—
Revenge his foul and most unnatural murder. (1.5.23-25.)
Caught up in the moment and eager to please his father, Hamlet swears to avenge his murder even before he's heard the story that his father came to tell him.
Haste me o know't, that I, with wings as swift
As meditation or the thoughts of love,
May sweep to my revenge. (1.5.29-31)
The Ghost tells Hamlet the story of his murder and makes his exit.
Adieu, adieu! Hamlet, remember me. (1.5.91)
Hamlet vows by heaven, earth, and hell to put everything aside until he has revenged his father's death.
Yea, from the table of my memory
I'll wipe away all trivial fond records...
And thy commandment all alone shall live
Within the book and volume of my brain,
Unmix'd with baser matter: yes, by heaven! (1.5.98-104)
Horatio and Marcellus come back to Hamlet to find out what happened in Hamlet's meeting with the Ghost. Hamlet makes a few cryptic remarks, then, with the help of the Ghost moving through the ground under their feet (1.5.148, 156, 161-162, 181), Hamlet makes Horatio and Marcellus swear on his sword, "Never make known what you have seen tonight" (1.5.144).
Hamlet also tells them that he's going to "Put an antic disposition on" (1.5.172)—in other words, he's going to start acting a little crazy—and that they must not pay any attention to his act or let anybody else know what's going on.
By now, Hamlet has calmed down from the excitement of seeing his father ghost and all the swearing, and he has a moment to think about the situation.
The time is out of joint: O cursed spite,
That ever I was born to set it right! (1.5.189-190.)
The meaning here is that time is like a bone that's slipped out of joint, and it's Hamlet's job "to set it right"—to set the bone back in place.
But Hamlet's clearly not happy about it. Denmark is a mess, and now he's got to clean it up. Here, "spite" might mean "revenge," and Hamlet is cursing the revenge that he has just sworn to undertake on his father's behalf. "Spite" could also mean that Hamlet feels that "the time," the world, and the universe are being spiteful towards him by forcing him into this situation. "Spite" might also mean his fate, and Hamlet is cursing the fact that he can't control it.
Just a few minutes after dramatically swearing by heaven, earth, and hell to avenge his father's death, Hamlet realizes the enormity of what he's tasked himself to do. Hamlet laments "that ever I was born," and he also resents the fact that his life is no longer his own, and it's now his sworn duty to revenge his father's murder and restore order to Denmark.