If the sentence “I must be cruel to be kind” were not such a well known and well used idiom it would seem very strange. On the face of it, the phrase is a contradiction that doesn’t appear to make sense.
The expression has become an idiom, something a father may say to a teenager when grounding her to protect her from something – possibly bad influences. “I must be cruel to be kind,” he may say. It means that he is doing her a small injustice with the aim of avoiding an even greater injustice or harm. It’s similar to the 19th century schoolmaster who sadly has to administer corporal punishment to a boy saying “This will hurt me more than it hurts you”.
“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 this speech, Hamlet is talking to his mother. It occurs after Hamlet has killed the eavesdropping Polonius with his sword. He first addresses that, saying he’s sorry, but that Polonius deserved it. Then he returns to the topic he was dealing with his mother, Gertrude, before stabbing Polonius. He has been reprimanding her for her closeness to her new husband, the villainous Claudius, calling him a “mildewed ear.” He explains that he has to be cruel to her only to be kind, to dissuade her from having sex with Claudius as that is a betrayal of her previous husband, Hamlet’s father. He is being very harsh but his intentions are good ones.
Certainly, he is being very cruel. He even threatens her. He tells her that if she suggests to Claudius that he’s only pretending to be mad, her neck might break.
However, as so often with Shakespeare, buried in a small passage of dialogue, there is a gem that is extracted from it and heightened to an immortal idiom. In this case, it is “I must be cruel only to be kind.”