This is the question most often asked about Hamlet, in one form or another. Why doesn't Hamlet just go ahead and kill Claudius? He makes some excuses to himself which do not sound entirely sincere or convincing. For instance, he tells himself in one of his soliloquies that the ghost he talked to might be the devil in disiguise. But he is still procrastinating up to the very end when he engages in a fencing match with Laertes and is wounded with a foil dipped in poison and finally kills Claudius in the heat of passion. We like Hamlet intelligent, funny, learned, charming when he wants to be--but we get irritated with his endless procrastination and introspection.
C. G. Jung, in his book Psychological Types distinguishes two "attitudes," introversion and extraversion, and four conscious functions, which he terms thinking, intuition, sensation and feeling. Jung's book has been used as the foundation of the Myers-Briggs Type Indicator (see reference link below). Hamlet, judging by the Myers-Briggs formula, would definitely be an introvert. His primary conscious function would obviously be thinking, and his complementary conscious function would probably be intuition. So he would probably be classified as ITNJ, or possibly ITSJ. The "J" stands for judgmental, and Hamlet is certainly that.
Jung emphasizes and repeats in Psychological Types that thinking and feeling are incompatible. A thinking person cannot have feeling as a complementary conscious function, and a feeling person cannot have thinking as a complementary conscious function. We can observe this in many people we have personally known, and perhaps also in ourselves. Now Hamlet's problem is that, as Coleridge observed long ago, he thinks too much, and his thinking paralyzes his action. Another way of putting it is that Hamlet needs to feel rage in order to commit a murder, however justified, and he can't feel murderous rage while he is thinking. The type of education he has received at Wittenberg has undoubtedly not only influenced his thinking but has also contributed to his confusion.
Hamlet can act forcefully and decisively when he isn't thinking. He boards the pirate ship single-handedly. He kills Polonius on the spur of the moment. He grapples with Laertes on impulse at the grave of Ophelia. He disarms Laertes during their heated fencing match and exchanges foils with him. Finally he kills the Claudius when he is still incensed from the duel and realizes the King's treachery.
Hamlet is essentially an introverted scholar who has an distasteful obligation thrust upon him to revenge his father's murder. He has studied at Wittenberg for many years and would like to go back there if Claudius were not keeping him a virtual prisoner at Elsinore. Laertes, by contrast, is an extravert whose primary conscious function is feeling. He doesn't stop to think when he barges into Claudius' private quarters and threatens to kill him and perhaps lead a spontaneous revolution. But Laertes' feelings interfere with his thinking, and so he is easily pacified and turned around by the wily Claudius (who is probably an ESTJ, pragmatic and cerebral).
Hamlet is indecisive; this ultimately will be his tragic flaw. He is a scholar, a student at the University of Wittenburg, so killing does not come easily to him. When the ghost reveals to Hamlet that Claudius is his murderer, he asks Hamlet to revenge "This foul and most unnatural murder." Hamlet is hesitant to exact this revenge. Not only is his conscience weighty, but also he is unsure of the ghost's true intent. He ponders if the ghost (as the Protestants would believe) is an evil entity assuming the shape of his familar father, but really trying to lure his soul to hell via the act of murder. Hamlet decides he must "catch the conscience of the king" -- in other words, decide if guilty or not, so he plans for the actors in Act III to perform a similar plot on stage as his the poisoning of his dad. He delays to get this reaction; he continues this procrastination when finally in Act V as he himself is dying, he kills Claudius.