Sometimes because people want help? Look at some libraries like matplotlib, or numpy. They're extremely useful, but they benefit because you have a team of developers working on it. Now, imagine that you're a company that sells services (data analysis, made to order applications, etc.)--it makes sense to open source the core (which is built from commonly known algorithms) and have that rock solid, because it is not your core competency.
Another example might be language translation. While there are open source (and even non gpl) libraries for western languages, unless ocrpus has advanced a lot recently, I didn't find much out their for Chinese (at least on English web sites). Writing a good online OCR library for Chinese is nontrivial and more than I'm likely to be able to do in my spare time--but, I might be able to get one started and open source it with a permissive license (so businesses can also contribute developer time) and have a community of people who might work on it if the groundwork is good. Now, people might use this for a variety of other applications (scanning, so-so machine translation, etc.) which might be profitable.
Otherwise--for some people we simply happen to have a "hobby" that could be profitable....
Another example might be language translation. While there are open source (and even non gpl) libraries for western languages, unless ocrpus has advanced a lot recently, I didn't find much out their for Chinese (at least on English web sites). Writing a good online OCR library for Chinese is nontrivial and more than I'm likely to be able to do in my spare time--but, I might be able to get one started and open source it with a permissive license (so businesses can also contribute developer time) and have a community of people who might work on it if the groundwork is good. Now, people might use this for a variety of other applications (scanning, so-so machine translation, etc.) which might be profitable.
Otherwise--for some people we simply happen to have a "hobby" that could be profitable....