There are many ways to make money with open source.
Or more specifically: whether you make money or not, is not (directly) related to the licensing of the software.
Yet there is only one way to make absolutely perfect code (with time ofcourse) and that is open source.
I don't know how you measure "absolute perfect code", but if you are talking about quality as in number of bugs in a released product, then what you say is certainly wrong. I would, again, say that this is not related to the licensing of the software.
And it's not even related to the kind of open/closed participation related to the project. It has more to do with the mindset of the devevlopers, and the amount of time (and potentially money) that a project is willing to spend on QA. And QA is not a fun job, you're a lot more likely to get people to do it when they are paid, than when expecting someone to show up and offer to invest his free time in it. (Again not directly related to the licnsing model of the distributed software)
So why is there opensource software? Here is one explanation from free software proponents: http://www.gnu.org/philosophy/free-sw.html
whis is one part of opensource software (see also: http://www.gnu.org/philosophy/categories.html
You'll find more general answers here:
http://www.opensource.org/advocacy/case ... siness.php