Talking of all God's wondrous works...remembering the "marvellous works that he hath done," the Psalmist writes--
Psalm 105:17 - He [God] sent a man before them, even Joseph, who was sold for a servant:
In selling Joseph, the sons of Jacob acted of their own sinful nature. When Joseph says of his brothers "But as for you, 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," he is clearly talking about the same thing, not two different events. What is the antecedent of "it"? God either meant it or He didn't. Joseph says He did. If any of us say otherwise, we say differently than God's word. God neither forced their actions nor simply knew in advance what they would do. It is that their evil, meant by them as evil, He chose to bring about good. Joseph would not have been in Egypt to deliver the sons of Jacob if they had not sold him in slavery (as well the rest of the chain of events where God's Providence put him in the exact places at the exact times). God chose that it be so. It would not be some other way. But his choice was not causative. He did not make the evil enter into their heart.
God is good in His means as well as in His ends. Is not Joseph's brothers selling him into slavery part of God's means? He might have theoretically gotten there any number of ways. But he did not. Neither does the Bible indicate that God meant that Joseph get there some other way. Did God have to wait to see what choice the brothers would make and then figure out something from there, in time? Or did He purpose from eternity what He would do?