God also knew Adam and Eve would eat the apple – why then create the tree of good and evil and put it in the garden?
God did not create two mechanical robots (Adam and Eve) and then program them to kneel and worship Him at some electronic signal. Rather He desired that human beings love and obey him willingly. Of course the only way this could be accomplished was to give them the freedom to do otherwise. God desires our worship but does not force it. Note Jesus’ words to the Samaritan woman in John 4:24.