Several years ago a few trees in my 15 acres of pine forest in Montana turned from green to a rusty brown, killed by swarms of bark beetles. Four years later virtually all of my centuries-old forest was dead. It wasn't just the beetles that did in my trees, but much warmer winters here in the Rocky mountains that no longer killed the bugs, allowing them to expand exponentially.

Since then, as a science journalist for the New York Times, I have written many stories about the dying of the trees – and the news is not good. Many forests across the length and breadth of the Rockies have died in the last decade. Most of the mature forests of British Columbia are gone, from a combination of climate and insects.

The bristlecone pines of the US – the most ancient trees in the world, with some more than 4,000 years old – will die in the coming years because of a combination of bark beetles and a fungal disease, enabled by a warmer climate. Tree-ring studies on the bristlecone show that the last 50 years are the warmest half century in the last 3,700 years.

All this is to say that the fungus killing ash trees in Britain is unlikely to be a one-off. Trees across the world are dying. It's not only the changes brought by a warmer world. We've treated the world's trees poorly for centuries, without regard to ecological principles. We've fragmented forests into tiny slivers, and selected out the best genetics again and again with no regard to the fitness of those that remain. Air pollution and soil abuse has taken a toll. And scientists admit trees and forests are poorly studied. "It's embarrassing how little we know," a leading redwood expert told me.

Yet the little that is known indicates trees are essential. They are the planet's heat shield, cooling temperatures beneath them by 10C and blocking cancer-causing ultraviolet rays. They are robust filters of our air and water, and soak up climate-warming carbon dioxide. Forests slow the runoff of rainfall. Many of the world's damaging floods are really caused by deforestation.

These functions are well known. But trees play many other critical roles that we know little about. Katsuhiko Matsunaga, a marine chemist at Hokkaido University in Japan, discovered that as the leaves from trees decompose, humic acid leaches into the ocean and helps fertilise plankton, critical food for many other forms of sea life. Japanese fisherman began an award-winning campaign called Forests Are the Lovers of the Sea, and planted trees along the coasts and rivers that rejuvenated fish and oyster stocks.

Also in Japan, researchers have long studied what they call "forest bathing". Hiking through the forest has been shown to reduce stress chemicals in the body and to increase NK or natural killer cells in the immune system, that fight tumours and viruses. Elsewhere researchers have demonstrated that anxiety, depression and even crime are lower in neighbourhoods with trees in the picture.

Hundreds of different kinds of chemicals are emitted by trees and forests, many beneficial. Taxane from the Pacific yew tree is a powerful anti-cancer drug. Many other tree compounds are proven to be antibacterial, anti-fungal, anti-viral and even to prevent cancer. The active ingredient of aspirin, acetylsalicylic acid, for example, comes from willows. Recommended by doctors to prevent a range of cancers, as well as heart attack and stroke, some believe this chemical in the wild has a medicinal impact on the health of all creatures as it is aerosolised into the air and water, and breathed in and drunk. Yet, it hasn't been researched.

Trees are greatly underused as an eco-technology – "working trees" – to make natural systems, as well as the world's cities and rural areas, more resilient. They are used here in the US to prevent soil erosion and shade crops. In a neat bit of alchemy, trees can be used to clean up the most toxic of wastes, including explosives, solvents and organic wastes, because of a dense community of microbes as thick as a finger around the tree's roots, a process known as phytoremediation.

The question is what to plant to withstand the challenges of a changing world to assure a world with trees. In the UK a group called Future Trees Trust is breeding more resilient trees. And a shade-tree farmer from the US named David Milarch, a co-founder of the Archangel Ancient Tree Archive, and whom I have written about, is making copies of some of the world's oldest and largest trees, from California redwoods to the oaks of Ireland – with proven survivor genetics – to be part of a future forest mix. "These are the supertrees," he says, "and they have stood the test of time."

Before I began this journey I felt planting trees was a feeble response to the planet's problems. No longer. As the proverb asks: "When is the best time to plant a tree?" Twenty years ago. "The second-best time?" Today.