Just like you would donate money to a charity you might decide to buy some stock in a company at IPO because you simply want to support their cause. It's also one of the reasons I bought an Ubuntu phone, I played around with it for a bit and ended up not using it because I'm too easily distracted.
If you're always looking for a return on every investment then you would have to decide against a lot of groups looking for money that need a shot in the arm in order to achieve their dreams, even if those dreams ultimately fail the road to that failed dream may yield useful spin-offs.
Investing is not all that black-and-white, and it is in general very hard to impossible to know which investments will yield a future return and which do not.
Investors that buy stock have fairly little say in the direction of the company until they achieve major interests, as such you're essentially along for the ride and if anything ever comes of it that is at the discretion of the majority interests in the company.
And once you have a majority interest you essentially own the company rather than that you are just an investor you are now at the helm.
Even VCs, who are arguably always looking for a profitable exit have no way to force such an exit other than to find a suitable partner and to activate what is known as a 'drag along' clause in the shareholder agreement (assuming that such an entry is present).
If they can't or that clause isn't there they are simply captive and will have to accept whatever dividend payments (or none) are issued by the company if the company ever turns a profit.
Canonical is a company that I think deserves a lot of praise and support for what they've done, even if it isn't the financial success that they might have hoped to achieve.
Obviously, given the fact that their product has been powering my desktop ever since I dropped 'Knoppix' makes me biased.