The phrase's meaning is that a bomb-maker is blown ("hoist", the past tense of "hoise") off the ground by his own bomb ("petard"), and indicates an ironic reversal or poetic justice.
[a] Hamlet has been acting mad to throw off suspicion that he is aware that his uncle, Claudius, has murdered his father and married his mother, Queen Gertrude, in order to usurp the throne.
Hamlet then accuses Gertrude of complicity in his father's murder, but when she protests her innocence, the two of them begin to conspire to reveal Claudius's guilt.
It is also a plot hole in that Hamlet, at this point in the play, has no way of actually knowing that Claudius plans to have him killed in England, nor even that Rosencrantz and Guildenstern are to be his travelling companions.
Hibbard, in The Oxford Shakespeare edition, agrees with Edwards that the omission of the speech increases the suspense in the F version.
[16] However, Ann Thompson and Neil Taylor, in The Arden Shakespeare third series edition, point out that Hamlet is not specifically planning to kill Rosencrantz and Guildenstern, he merely resolves to outwit them.
[16][11] The word "marshal" here begins a string of military metaphors: Hamlet sees his contest of wits with Rosencrantz and Guildenstern in terms of siege warfare.
[16][21] In the last two lines he savours the competition of two practitioners of cunning and schemes meeting head on, continuing the martial metaphor of mining and counter-mining.
[21][d] The Criminals are not only brought to execution, but they are taken in their own Toyls, their own Stratagems recoyl upon 'em, and they are involv'd them selves in that mischief and ruine, which they had projected for Hamlet.The speech is a central exemplar of a general theme or pattern in Hamlet: ironic reversal.
The plotters' plan was to have Gertrude, his mother, scold him for his antics while Polonius listened from hiding, in the hopes of learning whether Hamlet is truly mad or merely pretending.
[28] Ironic reversal was well known in sixteenth-century England and Elizabethan theatre inherited the tradition from Latin comedy and Christian thought.
According to Miles', the "Hoist with his own petard" speech is indicative of premeditation from Hamlet: it outlines future events and these are what actually turn out to take place.
In 1999 David Farley-Hills published an article in The Review of English Studies demonstrating that the relevant meaning was attested as early as 1450.
[34] He goes on to make an argument that the pirates were in collusion with Hamlet, and the attack a part of his plan already in mind during the speech in act 3, scene 4.