Please explain Hamlet's statement, "(T)he time is out of joint. O cursed spite, that ever I was born to set it right."
Hamlet has just finished talking to the ghost and finding out that his father was murdered by his uncle, Claudius. The ghost has left and Hamlet swears Marcellus and Horatio to an oath not to reveal what they have seen or what Hamlet is trying to do, even if he pretends to be mad:
There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy. ...
How strange or odd soe'er I bear myself,
As I perchance hereafter shall think meet
To put an antic disposition on,
That you, at such times seeing me, never shall,
... by pronouncing of some doubtful phrase,
As 'Well, well, we know,' ...
Or such ambiguous giving out, to note
That you know aught of me: this not to do,
So grace and mercy at your most need help you, Swear.
At first, the two men see no reason for swearing an oath but both Hamlet and the ghost insist. The ghost requires they swear:
Hamlet then laments that he is alive during this time ("O time is out of joint"). It's the time in which his father was murdered and, being the king's son, he is the culturally required person to "set things right." But he is not happy about it and laments being born at the time--out of joint, out of proper alignment--that requires he avenge his father's murder.
Culturally, revenge killings were the norm, as illustrated by Fortinbras. It is Hamlet's relatively new religious beliefs--beliefs in time out of joint, time out of alignment--that make revenge killing something to lament: Fortinbras accepts revenge killing for his father/King's death as an honor.
Hamlet is upset because quite a lot of things seem to be going wrong. First, his father dies. Then, his mother remarries incredibly quickly, and, still worse, she marries Hamlet’s uncle, her own brother (by biblical precedent), making him Hamlet’s new stepfather. This new stepfather, Claudius, allows Laertes to return to the continent, but he refuses Hamlet’s request to return to school in Wittenberg— a request which seems perfectly reasonable—all while insulting Hamlet’s masculinity. Now, Hamlet has learned that his uncle/stepfather actually murdered his father, the old king, in cold blood. Absolutely everything in Hamlet’s life seems out of whack—or "out of joint"—and he curses the fact that it really falls to him to avenge his father’s murder and set everything right again. It is certainly his job to do so, both as old King Hamlet’s son as well as the person who his father’s ghost appointed. He is now the only person, besides Claudius, to know the truth, and he must find a way to right all these wrongs done by others.
"Time is out of joint." In other words, time is dislocated. Time is not in the right place. Time is wrong. Time is broken.
Instead of Hamlet's dad being king and everything being 'straight', Hamlet's uncle has broken the true path of time and history by murdering The King and stealing his crown. Claudius has broken history and Hamlet was born at the time that requires he must fix it, whether he would or not.
"O cursed spite, that ever I was born to set it right"
Time is out of joint because the normal royal succession from father to son has been disrupted by Hamlet's uncle usurping the throne.