Hamlet has come to realize that we humans don't have control over everything and that fate plays a large role in our lives. We just have to accept that, work with that, and make the best of it. When he is talking to Hortatio he explains, "There is a divinity that shapes our ends, rough hew them how we will." He means that he get to make a lot of the decisions of our life (rough hew) but that God/Fate/Divinity shapes us too.
Later in the act, after Hortatio cautions him about going into this sword fight with Laertes, Hamlet says, "There is a special providence even in the fall of a sparrow ... the readiness is all." He is telling Hortatio that God is even aware of the death of insignifant bird like a sparrow, and that all Hamlet can do, ultimately, is be as ready and he can for what may come. He can't control anything but himself and his reaction to the events around him. This is a dramatic change from the man who accomplished very little for the first four acts of the play.
In the final scene of the play, Hamlet displays several significant changes in regards to his thoughts, feelings, and actions. Throughout the play, Hamlet has demonstrated his reluctance to comes to terms with death, particularly his own, and has shown his hesitance in regards to seeking revenge for the death of his father. Hamlet has also focused his attention towards his own feelings and family members, dismissing how his actions have negatively affected others, specifically Ophelia and Laertes.
In the final scene of the play, Hamlet's thoughts and actions reveal significant changes in his mindset. At the beginning of Act Five, Scene 2, Hamlet expresses to Horatio that he has come to terms with his destiny. Hamlet accepts the fact that God is in ultimate control and determines the fate of all humans. Hamlet also expresses his sympathy for Laertes. He tells Horatio that he understands Laertes's feelings because he too is in a similar situation. Hamlet says,
But I am very sorry, good Horatio, that to Laertes I forgot myself, for by the image of my cause I see the portraiture of his. (5.2.80-83)
Hamlet later apologizes to Laertes before their duel. In the climactic ending of the play, Laertes reveals that Claudius is responsible for poisoning the tip of the sword and the wine. Hamlet finally acts upon his emotions by mortally wounding Claudius and forcing him to drink the poisonous wine.