In act V, scene 2 of "Hamlet", what is the purpose served by Fortinbras' appearance at the end of the play? (its dramatic purpose)
His appearance is necessary to re-establish the civil order that has been disrupted by the murder of King Hamlet and then by the numerous deaths of those that lie slain on the stage. The Elizabethans of Shakespeare's day believed in the Chain of Being, which connected all of creation in ascending order beginning with inorganic matter and rising to God. The king was God's representative on earth so when the king was murdered, the civil order was disturbed. Not until the rightful king is on the throne will order be restored. Unfortunately in this play, Hamlet also dies so Fortinbras is next in line to claim the Danish throne. He is the highest ranking character on stage at the end of the play, and it is his responsibility to re-establish order in the chaotic kingdom of Denmark. Hamlet tells Horatio before the prince dies that Fortinbras should be king. Note that he is the one who gives the orders about how Hamlet is to be buried. Without Fortinbras' appearance at the end of the play, there is no resolution to the plot.
Fortinbras is a foil of Hamlet's and has shown that by taking action on what you set out to do that you will succeed in the end. Fortinbras has been seeking revenge for the death of his father and is looking to gain back lands that his father had lost. He, unlike Hamlet, takes action right away. We see this incident when Hamlet runs into the Captain who is telling of the purpose of Fortinbras attack on Poland. In Hamlet's soliloquy in Act IV scene 4, we see that Hamlet admires Fortinbras in a way because he is taking action and putting so much care into something that to Hamlet is not important. The end is showing us how Fortinbras's actions are rewarded by becoming King of Denmark.