The same decree of God which ordains the moral law that prohibits and punishes sin, also permits its occurrence. But it limits it and determines the precise channel to which it shall be confined, and the precise end to which it shall be directed, and overrules its consequences for good. The Bible clearly teaches us that. Listen again to this account of Joseph and his brethren in Genesis 50:20: ‘But as for you,’ said Joseph, ‘ye thought evil against me; but God meant it unto good, to bring to pass, as it is this day, to save much people alive.‘ And I suppose in many ways the most striking example of all is to be found in the betrayal of Jesus by Judas: a free and voluntary action, and yet a part of God’s great eternal purpose and plan.
Martyn Lloyd-Jones. Great Doctrines of the Bible.