The most important reason for Hamlet's tragic end is inability to kill Claudius when he had the chance.
Hamlet chose not to kill Claudius when he was praying because Hamlet did not want Claudius to go to heaven with a clean soul.
Claudius grieves about the guilt of killing his brother and for not able to pray. As he proceeds he kneels down to inspect his sins and not knowing if he can ask for forgiveness from God or not. Then enter Hamlet silently to kill Claudius and draws his swords. However, he pauses and says,
“And so he goes to heaven. And so am I revenged- that would be scanned. A villain kills my father, and, for that, I, his sole son, do this same villain send To haven. Oh, this hires and salary, not revenge.”
Therefore, Hamlet refuses to kill Claudius as he believed he will go to heaven while in process of praying. He thought sending Claudius soul to heaven would not be revenge as his father didn't get the opportunity to repent for his sins before his death. He wished to send his soul to hell for eternity and hopes to kill his uncle while he is drunk or gambling to let his soul suffer in hell.
Hamlet hopes by acting crazy Claudius would expose his guilt instead, Claudius in an assassination plot sends him to England. In return hamlet to devices a mouse trap scene wherein, the final analysis lead to his tragic flow due to his inability to decide about vengeance or ghost and therefore his act of revenge for his father's death leads to the bloody graves of Laertes, Polonius and Ophellia.