In Act Four, scene seven, of Shakespeare's play, Hamlet, Claudius offers two reasons to Laertes for why he did not punish Hamlet outright when the Prince killed Polonius.
It is important to remember that Claudius believes Hamlet is dangerous to his position on the throne. Whether through Hamlet's madness or firm intent, the Prince has become a threat and Claudius must get rid of him. He tried to have Hamlet executed by the English, but was thwarted when, through Hamlet's insightful machinations, Rosencrantz and Guildenstern were killed instead.
In this scene, Claudius is trying to manipulate Laertes' anger against Hamlet (another son who has unjustly lost a father) so that Laertes will be the instrument of Hamlet's destruction. Claudius promises that in no way will guilt then fall on either of them; but Laertes wants to know why the King didn't bring Hamlet up on charges for murder with the courts.
In convincing Laertes, the King first tells the young man that the Claudius was prevented from punishing Hamlet because Claudius loves Gertrude very much (whether that be a good or bad thing), and she dotes on her son so much, that he can do nothing that she would be unhappy with.
The Queen his mother
Lives almost by his looks; and for myself—
My virtue or my plague, be it either which—
She's so conjunctive to my life and soul
That, as the star moves not but in his sphere,
I could not but by her. (IV.vii.13-18)
The second reason Claudius gives for not punishing Hamlet is his popularity with the people of Denmark. He says that the populace so admires Hamlet that would be willing to overlooks his faults, and that things most people would judge to be wrong, they would excuse for Hamlet's sake. In this case, the people (who aren't really fond of Claudius to begin with) would find fault with the King, and Hamlet would go unpunished.
The other motive
Why to a public count I might not go
Is the great love the general gender bear him,
Who, dipping all his faults in their affection,
Would, like the spring that turneth wood to stone,
Convert his gyves to graces; so that my arrows,
Too slightly timber'd for so loud a wind,
Would have reverted to my bow again,
And not where I had aim'd them. (IV.vii.20-26)
It is with these two reasons that Claudius excuses himself for not having taken Hamlet into the public courts to have him tried and punished for Polonius' murder. (In truth, Claudius knows what he has done—murdering Old Hamlet—and cannot afford any public accusations from Hamlet.)