I must be cruel only to be kind. Thus bad begins, and worse remains behind.
In Gertrude’s closet, Hamlet has killed Polonius (thinking him Claudius) and confronted his mother about her marriage. The Ghost appears again, visible only to Hamlet. After it leaves, Hamlet urges Gertrude to repent, justifying his cruelty as a kind of love.
A paradox that entered common English. Hamlet justifies his harsh treatment of his mother as necessary medicine.