Software Isn't Everything!
It's often easy to forget that the software market, even taken as a whole, is a tiny fraction of the total industrial output of the world. Far, far, more people are involved in creating things-that-aren't-software than are involved in creating software. A lot of these things, however, require some software in their creation.
These days, almost anything nontrivial that you buy will run some software, and everything else will have been created or sold with the aid of some software. A lot of Free Software is funded by complementary markets. The existence of the software has significant value to the companies that make products using it.
A good example of this is Apple's work on LLVM. Apple hired the lead developer and pays a number of people to work on LLVM full time. Having a good compiler that it can use is incredibly important to Apple's business model. Before OS X, almost all Mac development was done with Metrowerks CodeWarrior. This made Apple entirely dependent on another company for their success.
With the introduction of OS X, Apple supported GCC and its own build environment. Unfortunately, GCC was controlled by the Free Software Foundation, and the license didn't permit several of the things that Apple wanted to do with it. The solution was to invest in LLVM, and Apple developers have released a huge amount of permissively licensed code as part of this project.
The fact that LLVM is Free Software is important to Apple, because it means that companies like Adobe, Cray, Google, and so on, who also benefit from the existence of good compilers, can easily fund some of the developer effort.
The trick with Free Software is to identify who benefits from it and persuade them that it's in their best interests to fund it. This is no different from any other product or service: You need to first identify your market and then turn people in your market into your customers.