“And don’t go near to this tree lest you be among those who wrong themselves.”
(Surah Baqarah, 35)
In spite of the actual prohibition being the act of eating from the tree, going near to it was proscribed, however. The reason for this is that Allah Ta’ala is exceptionally compassionate and benevolent. He foresaw that going near would make indulging in the forbidden act unavoidable. He therefore placed a ban on going near.
This is just as a father with loving care tells his child not to go near the fireplace, whereas he knows that being near to the fireplace is not harmful. But, he is furthermore aware that going near would ultimately lead to the dreaded act of being burnt. He therefore stops the child from even going near. (Ashrafut Tafaaseer