Grace brings salvation. We are saved by grace through faith. And it is grace that teaches us to live right and do right. That is why God’s first commandment started with a statement of grace. God provided absolutely everything that Adam would need according to His grace. Adam did not earn, deserve or occasion it. God freely gave him all things and allowed him to gorge himself on as much fruit as he desired. Grace gave Adam space.
This grace taught Adam to be obedient. The end result of receiving grace is wilful obedience. Romans 6:14 says that sin shall not have dominion, power, and control over you because you are not under the law, but under grace. Being under grace frees us from the dominion, power, and control of sin. Grace breaks the power of sin. God knew this. And that is why He first extended grace by telling Adam that he could freely eat of any tree that he wanted to before informing him of the tree that he was not allowed to eat from.
The presence of the tree of the knowledge of good and evil meant that sin and disobedience were possible. Adam could have allowed sin to have dominion, power, and control over him if he chose. But as long as he was under grace, it did not happen. We are not told how long Adam was in the Garden before Eve was tempted by the serpent. It may have been a short time, but it may also have been years. We do know that Adam at least named all the animals in that time. That could not have been a quick job!