A quick Google search reveals many theories. One is that the bright colors deter pests, signalling a healthy tree that will withstand attacks. Another theory suggests that the colors shield the leaves from damage from ultraviolet rays during a delicate time when nutrients are being shuttled from the leaves to the branches as part of getting ready for winter. Or perhaps the chemicals that make up the colors inhibit the destruction of chlorophyll, or maybe they help prevent frost injury to leaf tissues or limit water loss during dry spells in autumn.
In the end, no scientific theory offers a single, compelling explanation for the purpose behind leaves having bright colors in the fall. I have my own theory. Maybe there is no purpose. Maybe whoever or whatever did the basic design work of the universe just likes bright colors and ornate patterns.
It reminds me of the master craftsmen who would etch intricate swirls on the inside plates of pocket watches where no one could see them. In similar fashion, 17th Century scientists using newly invented microscopes discovered a hitherto unseen world of intricately wrought designs in full technicolor, a world created millions of years before the advent of humans.
The watchmakers added their hidden flourishes partly to show off their skills but also because they had a desire to go beyond utility to art. The skills are the result of practice, but the eye for beauty came bundled with their DNA. In the same way, could beauty be in the DNA of the universe? If so, from who or what was it inherited?
My theory applies equally to the purposeless ugliness that afflicts all of us from time to time as well as to purposeless beauty. The bad things that happen for no apparent reason clearly signal a high tolerance for misfortune without regard to the individual virtues of the victims. Fate doesn't play favorites. If this is not outright indifference -- which even an old agnostic like myself would be reluctant to accept -- than these terrible events are, for whatever reason, just as much a part of the DNA of the universe as is the inclination towards beauty.
The possibility of purposelessness -- be it beauty or beast -- does not exclude meaning. Each in it own way gets us thinking about the creative processes that underpin the universe. Like it or not, randomness -- another word for changes that happen for no particular purpose or reason -- is built in to every facet of existence. Randomness will sometimes produce beauty, be it galaxies swirling in space or autumn leaves swirling in the wind. Sometimes, that randomness has an uglier outcome ... a tornado wipes out the house across the street and leaves yours alone ... or maybe it goes the other way and you are wiped out .. the tornado doesn't know or care.
Either way, randomness is an essential part of the destructive creation that drives life forward in a natural world that often seems indifferent to our survival. It's been said that we live in a purpose-driven world, but perhaps the purposeless moments might offer a clearer look at the processes embedded within the worlds we inhabit.
In the end, I choose to focus on the beauty of the universe. I like to think that no matter what happens, beauty will outlast ugliness. It is in the nature of things.
Anyway, it's a theory.