What truths about himself does Hamlet discover at the end of the play?
For me, this is one of the most interesting things about the play, and brings up two of the most poignant quotes of the play. Hamlet has spent the entire play "thinking" about his actions and his lack of action. He has berated himself for not acting. He has talked to the players about how to act, to his mother about how to act, and even to Ophelia. He has tried to assure himself that the ghost was telling the truth and that Claudius did, indeed, kill King Hamlet. Through all of his, Hamlet is trying to keep control of himself and his circumstances. What he realizes by the end of the play is that isn't possible to have absolute control. In a very important conversation with Horatio, Hamlet tells him about what happened on the boat to England. Before he gets into the details of the story, he says that there are times
When our deep plots do pall; and that should learn us
There's a divinity that shapes our ends,
Rough-hew them how we will.
What Hamlet has come to realize is that no matter what choices we make to shape our lives, there is all kinds of fate that also play a part in our lives, and there is absolutely nothing we can do to control that. All we can do, he says later in Act 5, is be ready to act when the time (fate) comes. He is specifically talking about the upcoming fencing match with Laertes. Horatio is concerned that this will be dangerous, but Hamlet has stopped thinking he can control everything. Fate has brought him to this place -- the showdown with Laertes, with the King and Queen present. All he can do is be as ready as possible for what may come of this. I don't think we are to read the lines as fatalistic, but just realistic. Hamlet is not looking to die; Hamlet doesn't assume the worst; but he is ready for whatever comes his way. When tells Horatio his thoughts he even alludes to the gospel of Matthew saying:
We defy augury. There is special providence [fate,desitiny]in the fall of a sparrow. If it [death, vengeance] be now, 'tis not to come; if it be not to come it will be now; if it be not now, yet it will come. The readiness is all.
These ideas are what allow Hamlet to stop thinking and planning and checking himself,and to just act -- to just go into the fencing match with the best intention of winning and being ready for whatever may come his way.