The fencing match is the grand finale of the play. It leads to the deaths of Laertes, Hamlet, Gertrude, and Claudius. An ambassador from England arrives to announce the executions of Rosencrantz and Guildenstern. The match was arranged to enable Laertes to murder Hamlet in revenge for the deaths of Polonius and Ophelia. So all the main characters are wiped out except for Horatio.
Claudius has shown his cunning in arranging this lethal fencing match. He wanted to make it seem like a mere friendly diversion. But the idea of such a match as a means of getting rid of Hamlet appealed to him because he knew Hamlet would fall for it. When Claudius is scheming with Laertes in Act 4, Scene 7, he tells him of a French visitor named Lamont who had praised Laertes extravagantly for his fencing skill:
He made confession of you;
And gave you such a masterly report,
For art and exercise in your defence,
And for your rapier most especially,
That he cried out 'twould be a sight indeed
If one could match you. The scrimers of their nation
He swore had neither motion, guard, nor eye,
If you opposed them. Sir, this report of his
Did Hamlet so envenom with his envy
That he could nothing do but wish and beg
Your sudden coming o'er to play with you.
Claudius knows Hamlet will welcome the chance to fence with Laertes, and that Laertes, who takes great pride in his swordsmanship, will be equally anxious to fence with Hamlet. Claudius knows how to manipulate people. Claudius makes it more difficult for Hamlet to refuse such an encounter by creating a substantial bet between himself and Laertes. According to Osric:
The King, sir, hath wager'd with him six Barbary horses; against the which he has impawned, as I take it, six French rapiers and poniards, with their assigns, as girdle, hanger, and so. Three of the carriages, in faith, are very dear to fancy, very responsive to the hilts, most delicate carriages, and of very liberal conceit. V.2
To make the match even more appealing to Hamlet, the King has given Hamlet highly favorable odds. Osric tells Hamlet:
The King, sir, hath laid, sir, that, in a dozen passes between yourself and him, he shall not exceed you three hits; he hath laid on twelve for nine, and it would come to immediate trial, if your lordship would vouchsafe the answer.
The King is betting that Laertes would have to get three more hits than Hamlet out of twelve "passes" in order to win. That means Hamlet only needs to make five hits, because Laertes could then only get seven at most, and that would only exceed Hamlet by two. Claudius is giving Hamlet the most favorable odds as a further inducement to participate.
In order to make the proposed match seem even more innocuous, Claudius has intentionally commissioned the foppish, comical young Osric to serve as messenger and referee. Hamlet and Horatio are both amused by this man, and Shakespeare's whole audience is laughing at his language and behavior. Osric is created to disguise the very serious intention behind this fencing match. Claudius has deliberately bet against Laertes to create the impression that they are not in collusion but are rival bettors. The actual match is very tense because Hamlet wins the first two passes and the third ends with neither man being hit. Only the audience knows that Laertes' foil is uncovered and poisoned. Hamlet would have to avoid being hit for five passes in a row in order to win the match and keep from being killed. Laertes does not really care about winning the bet; he wants to kill Hamlet any way he can. In addition to tricking Hamlet, Claudius has tricked Laertes into believing he is the superior swordsman when the King knows Hamlet is much better.
The King has so little faith in Osric that he sends a Lord to verify that Hamlet truly intends to participate in the match immediately. This is partially to inform the audience of what is going to happen, because the audience might have been confused by Osric's inflated vocabulary and Hamlet's banter.
LORD: My lord, his Majesty commended him to you by young Osric, who brings back to him that you attend him in the hall. He sends to know if your pleasure hold to play with Laertes, or that you will take longer time.