Avian feathers are incredible display structures, especially in terms of colors. These structures allow the birds to attract mates and to serve as threat display to rivals, and in rare cases act as camouflage when the flora is also extremely colorful. Shape also can play a part, as it does in peacocks. As reptiles, birds have superior color vision compared to mammals, and any structure capable of superior color display would very likely become set in the population through sexual selection, regardless of its other advantages. Non-avian dinosaurs, with the same superior color vision, may also have used such structures for display purposes.
Avian feathers are incredible camouflage.
Although many small non-avian dinosaurs may have had the kind of camouflage we see on birds today, larger dinosaurs may have had a completely unique camouflage, perhaps like that of World War II merchant ships that, while gaudy, broke up their lines and made them hard to spot at sea. Any camouflage that hid non-avian dinosaurs from predators or prey would be a definite advantage. The most likely scenario is that the selective pressures outlined above acted in concert in shaping avian feathers. Dinosaurs were and are incredibly diverse, coming in all shapes and sizes. It is very likely that very early in their evolution, non-avian dinosaurs took to the trees.