Hamlet is joking when he tells Claudius that the name of the play is "The Mouse-Trap." Actually, we learn in Act 2, Scene 2 (Line 520) that the title is "The Murder of Gonzago." (Hamlet mentions to Ophelia in Act 3, Scene 3 that "The story is extant, and written in very choice Italian," revealing the depth of Hamlet's scholarship.)
His intention is to find out whether the ghost was telling the truth and Claudius actually murdered his father by pouring poison in his ear, as Lucianus does in the play-within-a-play. Both Hamlet and Horatio are watching Claudius closely. When Claudius sees his own foul deed reenacted before his eyes, he is horrified and flees the stage. This convinces Hamlet that Claudius is indeed guilty of his father's murder. He tells Horatio, "I'll take the ghost's word for a thousand pound." The importance of this scene is that it fortifies Hamlet's motivation to assassinate Claudius. However, at the same time, it makes Claudius so suspicious and so frightened of Hamlet that he decides to get rid of him by sending him on a mission to England with Rosencrantz and Guildenstern carrying secret orders to the English to kill Hamlet immediately upon his arrival. Claudius still doesn't know whether Hamlet is mad or pretending, but he wants him dead. Hamlet now fully intends to kill Claudius but cannot do so immediately because he has to embark for England.
Because of the uproar created by "The Mouse-Trap," Gertrude sends for her son to upbraid him for causing it. Polonius hides behind a tapestry to eavesdrop on their interview and ends up getting stabbed to death by Hamlet, who probably mistakes the old man for the King. Polonius's murder has often been identified as the turning point in Shakespeare's play. This eventually leads to the fencing scene in which Laertes uses a foil with a poisoned tip to kill Hamlet in revenge for his father's death and his sister Ophelia's subsequent suicide. This violent finale in which Hamlet, Laertes, Gertrude, and Claudius all die resulted from what happened in "The Mouse-Trap" scene.
The Mousetrap is the center of the play. When done correctly it shows 2 plays going on at once. The outer play where Hamlet fences with Gertrude, Claudius, Polonius and Ophelia and the inner play -The Mousetrap- which is itself also two plays. The first which might properly be called "The Mousetrap" is aimed at Gertrude. See 3.4.185 where Hamlet says to Gertrude, "Pinch wanton on your cheek, call you his mouse." Hamlet wants to test Gertrude's involvement in the poisoning of his father. She of course passes the test.
The next scene is directed at Claudius called "the Murder of Gonzago." This is a very ambiguous scene. Each viewer sees what he/she wants to see. Hamlet sees the scene as a king being poisoned as the Ghost described it to Hamlet. But Hamlet also tells us that Lucianus is the nephew to the king. Because the stage audience does not know what we know, they see a nephew killing his uncle the king. So when Claudius flees the play is he fleeing because he has a guilty conscience or is he fleeing from the insult and threat? It actually is both. Claudius runs off to his prayer scene. Polonius, Gertrude, Rosencrantz and Guildenstern see the display as a distasteful prank.
This centerpiece is meant to highlight how image can be reality and the ambiguity between the two. It also shows some real clever writing as Shakespeare keeps two plays moving at the same time. Notice how Shakespeare moves from prose to blank verse to stylized poetry and back again. As the play begins Hamlet engages in Stichomythic prose with the other characters right through the entrance of the dumb show. This is briefly broken only by the Prologue's three lines of rhyming iambic tetrameter that with all of Hamlet's loquacity seems pointed right at him.
Ultimately, what Hamlet feared in his "to be" speech is coming to pass. The King is is now hunting Hamlet.