It was a test of obedience. It must be remembered, Adan and Eve were created after the fall of Lucifer. There is a great deal more to Lucifer's fall than most realize. He deceived a third of the Heavenly host and they rebelled against God.
This changed the order of things. From that moment on...