As far as I understand, all life started as non-flying and flying came about by natural selection. What is the evolutionary advantageous "path" to flying? Or is there something else to explain this?
The honest answer to this and many other similar evolutionary questions is that we don't know the answer. We can sample information from many different points along an organism's developmental timeline using the fossil record, genetics, etc. and reconstruct various states of said organism's development. The overwhelming evidence is that evolution is the process that connects these various states, but reconstructing the detailed trajectory that leads from one developmental state (e.g. flightless) to another (e.g. flying) is often formally impossible due to the low time resolution of the information that we have.
That being said, plenty of people have speculated as to the origins of flight, and there's an excellent wikipedia article on the subject. From the article:
Powered flight has evolved only 4 times (birds, bats, pterosaurs, and insects)... Insects were the first to evolve flight, approximately 350 million years ago. The developmental origin of the insect wing remains in dispute, as does the purpose prior to true flight. One suggestion is that wings initially were used to catch the wind for small insects that live on the surface of the water, while another is that they functioned in parachuting, then gliding, then flight for originally arboreal insects.