וַיְצַו֙ יְהוָ֣ה אֱלֹהִ֔ים עַל־הָֽאָדָ֖ם לֵאמֹ֑ר מִכֹּ֥ל עֵֽץ־הַגָּ֖ן אָכֹ֥ל תֹּאכֵֽל׃
און גאָט דער האַר האָט אָנגעזאָגט דעם מענטשן, אַזױ צו זאָגן: פֿון אַלע בײמער פֿון גאָרטן מעגסטו עסן;
Chizkuni
ויצו ה' אלוקים על האדם; “the Lord G-d issued a command to Adam, etc.” This is not to be considered as a test which G-d wanted to subject Adam to, seeing that He knows all that was, is, and will be. He commanded Adam not to eat from the tree in order to demonstrate to the angels who had appealed for G-d’s mercy on his behalf, that this Adam to whom they had looked with that much respect and almost awe, did not even have the power to resist the only temptation to which G-d had subjected him. Our sages in Sanhedrin 56b derive from this verse that G-d issued the seven universal commandments for mankind at this time. Each of them is hinted at in the words of this verse.
Sforno
מכל עץ הגן, depending on which tree’s fruit was in season. Each season required nutrients appropriate to the prevailing climate, and the fruit ripening during the various seasons would provide man with these nutrients. The prophet Ezekiel 47,12 expresses this thought in the words לחדשיו יבכר “in its appropriate month it will yield new fruit.”
Or HaChaim
ויצו השם אלוקים על האדם. The Lord G'd commanded Adam. The Torah added the word לאמור, to say, and repeated the word for "to eat," by saying אכול תאכל. The Torah also repeated that violating the command would result in death by saying: i.e. מות תמות, instead of merely תמות. The reason is 1) that Adam should command Eve not to eat from the tree of knowledge either; b) that the penalty would apply to her just as much as to Adam himself (who had heard the commandment from G'd directly). The repetition of these words also constitutes both a warning and a spelling out of the penalty, something that halachah demands when capital punishment is involved.