Even before the Garden, there was a plan prepared. The events of the Garden did not surprise God, they were fulfillments of his plan, a plan laid out in the pre-mortal life.