This is the play that Hamlet asks a traveling troupe of actors to perform. Rosencrantz and Guildenstern originally asked the troupe to perform at the castle, and Hamlet is delighted when he discovers they are coming. Hamlet adds some lines to the play to be spoken by the actors.
"The Murder of Gonzago" mirrors the events that have occurred in Denmark, specifically Claudius's murder of King Hamlet. The play is about a king who is poisoned by another man, but before the king dies, he talks with his wife about love, death, and remarriage. This scene is where Hamlet has asked the actors to add lines in the play that reflect what Hamlet what Hamlet wants to test about Claudius's regicide and his mother's betrayal of his father.
In "The Murder of Gonzago," the queen promises never to remarry, especially not someone who murders her husband, but the king says she will forget her promise once he is gone. Claudius takes offense at the scene and, when they get to the point where King Gonzago is poisoned, Claudius gets up and leaves. Hamlet determines he has proven that Claudius killed King hamlet, Hamlet's father.
This is the play within a play. Hamlet asks traveling actors to put on a play that is similar to the circumstances of his father's death. Hamlet also inserts lines into the original play to sharpen the focus on King Hamlet's murder. Hamlet and Horatio carefully watch King Claudius for any signs of recognition or guilt, recognition that Claudius does reveal. This is the proof that Hamlet needs to determine that the Ghost is an honest ghost and that Claudius did kill King Hamlet.