When the players first arrive, Hamlet talks with them and asks them to reenact a scene from a play that he saw them do once before. The story of Priam's slaughter echoes some of the same themes that Hamlet himself is dealing with, and this play inspires Hamlet. He remembers another play, The Murder of Gonzago, and asks the players if they know the play. When they reply that they do, Hamlet states that he would like to change about a dozen lines of the play and have them enact the play for the court the following night. At first the audience might be puzzled about what Hamlet plans, but in the following soliloquy he reveals that it is with this play that he hopes to "catch the conscience of the king." He plans to use this play to reenact Claudius's murder of King Hamlet. He plans to change enough of the original story so that it more closely matches the exact circumstances of Claudius's actions. Hamlet is hoping that when Claudius sees the play that he reveals his guilt in some outward way so that then Hamlet can be assured that the ghost was, in fact, a true ghost who was telling the truth and not a devil in disguise trying to damn Hamlet's soul by tempting him into evil action against Claudius. Hamlet is slow to act to because he wants to be sure he is justified in his revenge against Claudius. In Act 3, the "play-within-the-play" is completed and Claudius is so upset that he leaves the room in a hurry, thus proving the plan to be a success!
After everyone departs, Hamlet holds back the First Player and asks him if he can play the Murder of Gonzago. When he acknowledges that he can, Hamlet directs that it be presented "tomorrow night". He then asks if the First Player could study some lines that would be inserted into the play. The First Player accepts that as well.
As we shall see in the soliloquy to follow, Hamlet is going to use this little production to catch the conscience of the King. But it is more than that. The twist he is putting into the play of the additional lines will turn the play into "The Mousetrap". Foremost in his mind is his mother's fall from grace and he intends to catch her too. If, that is, she had a part in the poisoning of King Hamlet.
When the players and audience are assembled in 3.2, the whole first act is taken up with probing the conscience of the Queen. She appears to pass the test. When the Murder of Gonzago appears however, the king does rise and leaves the play. It would seem Hamlet has caught a rat! The irony of course is that Hamlet has run his mouth a little too much at the end and given the audience the notion that the play is about a nephew killing the King.