For this same lord,
I do repent: but heaven hath pleased it so,
To punish me with this and this with me,
That I must be their scourge and minister.

– William Shakespeare

Hamlet, Act 3, Scene 4. Hamlet realizes that he will eventually be punished for killing Polonius. But he also believes that it is the will of God he be the instrument of vengeance and punishment. He thinks that getting revenge is what God wants him to do.