Hamlet has spent the entire play taking great care in his actions and considering the consquences of his actions. He considers suicide, but rejects the idea because it is against God's laws. He takes the command of the ghost seriously, but wants to make sure the ghost is a true ghost, so goes about finding proof of Claudius' guilt before trying to kill him. He speaks in several soliloquys about his lack of action and why it is part of some people's nature to be thoughtful about their actions. But by the time he returns from the aborted trip to England he has a new outlook. He tells Horatio in Act 5 that "there is a divinity that shapes our ends rough hew them how we will." He is finally able to understand that while he has free will, fate it also an inevitable factor in life's events and one can only have so much control. Later he says, "there is a special providence in the fall of sparrow ... the readiness is all." He is again saying that God knows all things and we don't have complete control, all we can do is be as ready as we can for life's events. He knows that he is possibly heading into a dangerous fight with Laertes, but he is giving himself over to readiness and fate -- kind of saying, 'what will be will be.'
Basically, Hamlet is a play about growing up. At the start of the play Hamlet still believes life should be beautiful and perfect and people should be good and honest. He is shocked and angry when he discovers that many people are not good nor honest. He thinks life should have deep meaning but he can find no meaning at all.
Through the play he struggles to accept that life is painful and difficult. All the beautiful things he believed are gradually destroyed and he becomes depressed and suicidal.
Near the end of the play he changes, he becomes colder and less emotional. He has no hope but he no longer cares. He accepts life is meaningless. Instead of 'thinking about everything', he acts. He has his old friends murdered. He kills his Uncle and Laertes and accepts his own death.