Hamlet:Hamlet Act 3, scene 4, 173–179
I do repent; but heaven hath pleas'd it so
To punish me with this, and this with me,
That I must be their scourge and minister.
I will bestow him, and will answer well
The death I gave him. So again good night.
I must be cruel only to be kind.
Thus bad begins and worse remains behind.
In these lines addressed to his mother, Hamlet speaks of two different cruelties. In the first five lines, the prince refers to his own impulsive killing of the courtier Polonius earlier in the scene. Polonius had been snooping on Hamlet's meeting with his mother; and when Hamlet noticed someone stirring behind an arras (wall-hanging), he ran him through—and so ended Polonius's career. Hamlet rationalizes his deed—about 150 lines after the event—by getting the heavens involved: he's "their scourge and minister," he claims, chosen to visit justice on the corrupt. Polonius deserved what he got, but nonetheless Hamlet repents, and prepares to suffer the consequences: Polonius was punished by Hamlet, and Hamlet will be punished for killing Polonius.
But when Hamlet says he "must be cruel only to be kind," he's shifting his attention back to his mother. He has spent the better part of the scene upbraiding her for indulging her new husband, King Claudius, whom Hamlet compares to a "mildewed ear" [see FLAMING YOUTH]. He must be cruel to his mother, he explains, only to be kind to her—to save her from lapsing any further into sensuality and betrayal of her dead husband. The sentiment—harsh medicine may effect the best cure—is ancient, but Hamlet apparently coins "cruel to be kind," a very common phrase nowadays.