The answer is simple yet very complex - it comes from the air.
Trees like all plants carry on the process of photosynthesis.
Photosynthesis is the process by which plants utilize the energy from the sun to make sugar from carbon dioxide in the air. The next time you look at a tree think about the fact that what you see was once nothing but a bunch of carbon dioxide gas. This simple equation reveals much about a plant. First its obvious they need sunlight to survive. Different trees are adapted to grow under different levels of light.