Like the final scene of any play, the last scene of Hamlet provides the resolution of all of conflicts of the play. This play's primary concern has been Hamlet's need to avenge his father's death by Claudius. In this final scene, Hamlet accomplishes his goal; unfortunately, that goal is achieved as he learns that he too has been killed by the deadly poison. What is important to note in the final act is that before Hamlet goes into the fencing match with Laertes, he tells Horatio that he has finally come to understand that we humans can't control everything in our lives: "there is a divinity that shapes our ends, rough hew them how we will." Once Hamlet can give himself over to fate and a recognition that all he can do is be READY to act, he actually frees himself to act -- something he has not done throughout the play to any great degree. This point is the conclusion of the action vs. inaction theme.
Hamlet and Claudius's deaths leave Denmark without a royal leader, hence Fortinbras's arrival is fortuitous. Hamlet's dying words to Horatio are that he "sets his election lights on Fortinbras." This means that Hamlet is handing his blessing on Fortinbras's take-over of the throne. It is Hamlet's one kingly act -- ensuring some stability to his kingdom (though a foreign ruler could be problematic.) Nonetheless, Fortinbras serves to provide a closure to the state of Denmark at the end of the play. Osric is only a messenger/courtier of the king, but Horatio's presence at the end of the play provides Fortinbras and the people of Denmark with a justification for all that has happened in the court this last day. If Horatio weren't there to tell the WHOLE story, then it would look like Hamlet went on a murderous rampage. Horatio can reveal the mischief of Claudius and Laertes, and explain the deaths of everyone on the stage. All of these events leave all of the themes completed and all of the conflicts resolved; unfortunately, it is a very bloody resolution.