The earliest filamentous feathers appeared in dinosaurs well before birdsever did, and were present in plenty of species that had no hope of taking to the air (though I for one would love to see a flying tyrannosaur). So then, what might their original function have been, and what prompted them to be maintained, grow larger and change over time? The exact answer is sadly unknown. It is likely a number of factors in concert, or different ones having greater importance over others at various times, and piecing those fragments together is very tricky. However, there are some strong leads and ideas, and for some feather types in some groups the answer is rather convincing.

To deal with the central issue though, there are in fact various things that feathers may offer animals aside from flight alone. A quick look at living birds reveals plenty of possibilities, and almost all of them may be applied to various (or even all) dinosaurs that preceded true, powered flight. There really are quite a few, so I'll try to be brief, but it shows just how many selective pressures may have acted on feathers and led to their spread and development across the various dinosaurs that had them.

Most obviously, there's temperature regulation. Birds typically maintain a high body temperature and so keeping that heat in requires some form of insulation. While it's uncertain as to the physiological state of various dinosaurs at least some were almost certainly bird-like in metabolism. Even those that were not might still have benefited from insulation (see also fuzzy things with odd physiology like the platypus and moths) so that doesn't rule it out, and of course they could also use these feathers to insulate eggs or young animals, and we do know many dinosaurs were good parents and even brooded on nests. Similarly, feathers can help keep things cool by providing shade (again, eggs and babies in particular might benefit), but it's also possible that they aided cooling since feather vanes have a blood supply, this could be used to shed some heat by bringing blood up to the surface of the animal.