They needed that. It was their opportunity to love Him, to believe Him, to trust Him. And they had many other opportunities.
As do we.
God's Name is I AM!
either God did it or permitted it.
God's perfect will or God's permissive will
And we know that all things work together for good to them that love God, to them who are the called according to [his] purpose. - Romans 8:28
Given this, one of my favorite verses BTW, Are there really any mistakes or errors in a child of God's life?