"I found that the very commandment that was intended to bring life actually brought death. For sin seizing the opportunity afforded by the commandment, deceived me, and through the commandment put me to death. So then, the law is holy, and the commandment is holy, righteous and good." Romans 7:10-12
God is for life, He is the giver of life and He is the sustainer of life. He is good.
There were two trees in the middle of the garden. God's intention was for His image bearers to eat from the tree of life. The commandment given was intended to bring life. The commandment not to eat of the tree of knowledge of good and evil was meant to direct Adam's attention and desire to the tree that would bring eternal life. By eliminating the option of eating from one of the trees in the middle of the garden it served to lead him to the
next closest option.
May our hearts be right towards God, let us remember He is for life. If He closes a door or warns us away from certain enticements or people or influences, it is for our good. He knows the path to life. May He direct us rather than leaning on our own understanding.