In Parshat Shoftim (Dvarim 20:19-20), we read:
If you besiege a city many days to wage war against it to capture it, do not harm any of its trees by chopping it with an ax, because you eat from it you are not to cut it down; For, is the tree of the field a person to join the besieged to escape you? Only a tree that you know that it is not a fruit tree may you harm or cut down; and you will build battlements against the city that is waging war against you until it is conquered.
According to Ibn Ezra, human life is dependent on the tree of the field for food.
The same way that we are not allowed to take away a person’s work tools (even in the case of security for a debt) since by not having their tools they would no longer be able to make a living, so too we are not allowed to cut down a fruit tree for no reason as we are dependent upon the tree for our nutrition.
In the Talmud, Bava Kama 91b, we learn that when it is necessary to cut down trees, the non-fruit trees should be cut down before the fruit trees.
There are situations when fruit trees can be cut down for example if the tree is more valuable for its wood than for its fruits, if the tree is detrimental to its surroundings (damaging other more valuable trees) or if it occupies space that is needed.
The fact that there are discussions about the importance of the trees in both the Torah and the Talmud teaches us that Judaism has always been focused on protecting the environment. By taking care of our surroundings we are in turn also making this world a better place for us to live.
According to Ramban, we should keep a positive attitude even at a time of war. We must trust in God and not unnecessarily destroy the trees. If we are able to protect the trees, not only will we be taking care of the environment but if we are victorious we will have food to eat and a beautiful place to live with nature still intact.