Sometimes it's easy to understand why an evolutionary change took place, but it's more difficult to understand how. For example, consider the beautiful birds of paradise which live in the forests of New Guinea.
The males of many bird-of-paradise species have evolved colorful plumage used for dramatic courtship displays. Why this plumage evolved is no mystery: the healthiest males usually have the most spectacular plumage, so females choose whichever male has the gaudiest feathers.
With this criterion, it's not surprising that male plumage would grow more and more elaborate over the generations. Understanding how the plumage evolved is a little trickier.
After all, there are some bird-of-paradise species that are really quite drab. These birds devote most of their energy to finding food and raising their young, instead of wasting it on courtship. What makes these near neighbors so different? The answer is diet.
Those species with the most elaborate plumage also have the most diverse and reliable diet: a variety of insects and fruits rich in complex nutrients. With this healthy, reliable food supply, females can raise the hatchlings without help from the males.
This frees the males for their extravagant courtship behavior. The complex diet also provides them with chemicals to make their brightly colored feathers.
In contrast, the drabber birds have a limited diet of simple figs, which are available more sporadically. They're monogamous, and both parents need to spend most of their time foraging. This means less time for elaborate courtship behavior.
So different diets lead to different behaviors, which results in the evolution of different plumage. These exotic birds show just how complex evolution can be!
Beehler, Bruce M. "The Birds of Paradise." Scientific American, December 1989, pp 116‑123.