Why is Hamlet given a military funeral?
It's a measure of Fortinbras's innate nobility that he recognizes a kindred spirit in the deceased Hamlet. Strictly speaking, though, Hamlet wasn't a soldier; he never fought for his country. But in a way he did fight; he fought for a noble cause. Though instead of fighting a foreign power, he fought against his wicked uncle's usurpation of the Danish throne. To be sure, he took his time about it, but he got there in the end. He received his orders from his father's ghost and eventually did carry them out, although the tactics he used were far from conventional from a military standpoint.
Yet perhaps Fortinbras is mistaken as to Hamlet's true nature. He declares that Hamlet, had he lived, would've made an excellent king. But how would Fortinbras know that? The short answer is that he doesn't. In giving the deceased prince a military funeral, Fortinbras is simply showing due propriety to established tradition.
Ignoring the moral complexity of Hamlet's character is also a smart move politically. Fortinbras may not know much about what Hamlet was really like, but he does know how popular he was with the Danish people. Giving him a burial worthy of a great and noble warrior immediately puts Fortinbras on the side of his new subjects. This is a highly skillful act of propaganda that should conduce greatly to the long-term stability of Fortinbras's new throne.
Fortinbras is not Danish; in fact, he is from Norway. And, to boot, Denmark and Norway were, apparently, at odds prior to the start of the play, as Fortinbras is angry about his father's death at the hands of Hamlet's father's forces. In other words, it seems possible that the Danes would be reluctant to accept Fortinbras's rule of Denmark, especially after all the drama and upset that have taken place in the Danish court: first Hamlet's father dies, then the queen remarries her brother-in-law so quickly, and now Polonius, Laertes, Ophelia, Claudius, Gertrude, and Hamlet are all dead. Therefore, despite Fortinbras's evident claim to the throne—he references his "rights of memory in this kingdom, / Which now to claim [his] vantage doth invite [him]" (5.2.432–433)—he may feel the need to make peace with Denmark and its people. Thus, his first act as Denmark's ruler will be to treat Hamlet with respect and honor and to begin to restore order to the court which has been "much amiss" (5.2.448). It seems like a good way to lay to rest all of the strife and dishonorable actions that have recently characterized the court and country.
He gets a military funeral in order to show that, because he finally acted, he emerged as a better and different person. Fortinbras, whose action is contrasted with Hamlet's earlier inaction, is at the funeral and praises Hamlet. More info at the link below.
Hamlet is Prince of Denmark.His uncle had usurped his father's throne after murdering him.In the end when the conspiracy is revealed and hamlet murders his uncle . Unfortunately he himself is injured in the duel and he dies. After his uncle's death he ascends his father's throne and is given a military funeral by Fortinbras,Prince of Norway who admires Hamlet.