Act IV is pivotal to the play's plot because it shows the consequences of Hamlet's plan to flush out Claudius as his father's murderer. First of all, Hamlet has orchestrated a play that so mimics his father's murder that Claudius, through his actions and overheard confession, has admitted his crime. Second, Hamlet's has killed Polonius, his girlfriend's father, while arguing with this mother.
The consequences of these actions are astounding. First, Gertrude must choose between her son and her husband. She chooses her son when she confirms to Claudius that Hamlet is crazy. She notes,
Mad as the sea and wind, when both contend
Which is the mightier; in his lawless fit,
Behind the arras hearing something stir,
Whips out his rapier, cries, 'A rat, a rat!'
And in this brainish apprehension, kills
The unseen good old man."
While this murder draws Claudius' attention away temporarily, Ophelia, his girlfriend goes crazy and commits suicide while her brother Laertes returns looking for blood. This quest eventually leads to Hamlet's death as well.
Claudius sends Hamlet away with the point of having him killed, but Hamlet thwarts this plan only to return to another, more fatal deception.
Act Four provides the consequences for Hamlet's actions in Act III and sets up the final act in which all the principal characters die.