Hamlet is scared because he does not know what happens after you die. He is not afraid to die, but he will not kill himself because he is afraid that he will go to hell. In act 3 scene 3, Hamlet shows his belief in the bible by not killing his father while he is in prayer. He says,
A villain kills my father; and for that,
I, his sole son, do this same villain send
According to the bible, if you repent of your sins you will be forgiven and go to heaven when you die, Hamlet believes this and that is why he does not kill Claudius in this scene. Another reason he does not kill his Claudius based on the reason above, he will not give Claudius the glory of going to heaven when Claudius did not give his father the choice to repent of his sins before he was killed.
Hamlets belief in what happens after you die first came about after his fathers ghost tells him about his experience with dying before repenting of your sins. In act 1 scene 5, the ghost of Hamlets father says,
Doom'd for a certain term to walk the night,
And for the day confined to fast in fires,
Till the foul crimes done in my days of nature
Thus was I, sleeping, by a brother's hand
Of life, of crown, of queen, at once dispatch'd:
Cut off even in the blossoms of my sin,
No reckoning made, but sent to my account
With all my imperfections on my head:
O, horrible! O, horrible! most horrible!
The line Doomd for a certain term to walk the night, and for the day confined to fast in fires shows Hamlet that his father is neither in hell nor heaven, but in some kind of middle world, but still on the earth at night, maybe in hell in the day. This idea troubles Hamlet because now he knows that his fathers soul is not in peace. He also learns that the reason his father is in this place is because he was murdered before he could repent of his sins. Hamlet feels that he has some duty as the ghosts son to revenge him in hopes that it will fulfill his fathers journey to heaven or hell, because the current state that he is in seems worse than either of those.
Hamlet may also think that Denmark is a place between heaven and hell as his father is in another place between heaven and hell. A quote from act 2 scene 2 shows this,
A goodly one; in which there are many confines,
wards and dungeons, Denmark being one o' the worst.
Here, Hamlet refers to Denmark as a prison, where he cannot escape. It seems as though he wants to get away from the new king and get out of being prince. Or he sees the world as a prison keeping him from reaching heaven, like some kind of other hell that is not purely hell nor heaven. But he ensures that the whole world isnt a hellish prison, but you can infer from him saying Denmark is the worst prison, that it is the most hell-like place on earth in his mind.
The gravedigger scene in act 5 scene 1 shows the most about how Hamlet feels about death. Hamlet refers to the skulls he finds belonging to other people and their past lives.
That skull had a tongue in it, and could sing once:
how the knave jowls it to the ground, as if it were
Cain's jaw-bone, that did the first murder! It
might be the pate of a politician, which this ass
Or of a courtier; which could say 'Good morrow,
sweet lord! How dost thou, good lord?
There's another: why may not that be the skull of a
lawyer? Where be his quiddities now, his quillets,
his cases, his tenures, and his tricks?
in's time a great buyer of land, with his statutes,
his recognizances, his fines, his double vouchers,
his recoveries: is this the fine of his fines, and
the recovery of his recoveries, to have his fine
Everyone was something during their life, and then they die, and their body returns to the earth. Hamlets attitude toward this is that, in the end, it doesnt really matter what you did during the time when you were alive. Every worldly possession that someone has is gone once they die; there is nothing anyone can do about it. They still go back to the earth and get their fine pate full of fine dirt.
The most important speech in act5 in this speech that shows the most about Hamlets feelings about death is this,
No, faith, not a jot; but to follow him thither with
modesty enough, and likelihood to lead it: as
thus: Alexander died, Alexander was buried,
Alexander returneth into dust; the dust is earth; of
earth we make loam; and why of that loam, whereto he
was converted, might they not stop a beer-barrel?
Imperious Caesar, dead and turn'd to clay,
Might stop a hole to keep the wind away:
O, that that earth, which kept the world in awe,
Should patch a wall to expel the winter flaw!
From this you could speculate that Hamlet believes that after you die there is a part of your soul, or part of the person, that is left behind. More than just the bones and flesh that are devoured in the ground by worms, but part of who they were. The line Imperious Caesar, dead and turnd to clay, might stop a hole to keep the wind away: O, that the earth, which kept the world in awe, should patch a wall to expel the winter flaw! shows this very well, because Hamlet talks as if the clay that Caesars body turned into had some sort of importance or value just because it was part of the physical Caesar. You may also think a person never truly dies, since their body still remains even if it is turned into a beer-barrel cork or a patch on a wall. So in essence, Hamlet believes that a persons soul is to go to either hell or heaven, but still part of them is left behind. What part of them that is left behind Hamlet does not specify, but there has to be something since he refers to a dead physical body of an important person having meaning.
The finding of Yoricks skull troubles Hamlet greatly because he remembers him when he was alive, and how he affected Hamlets life in a positive way.
Here hung those lips that I have kissed I know
not how oft. Where be your gibes now? your
gambols? your songs? your flashes of merriment,
that were wont to set the table on a roar? Not one
now, to mock your own grinning? quite chap-fallen?
Here, Hamlet really gets a feel for death. You can tell his emotions are sad and sorrowful by his reaction to finding the skull. He says he hath borne me on his back a thousand times; and now, how abhorred in my imagination it is! my gorge rims at it. That line shows his emotions of finding the skull as abhorred, which is a synonym of hate.