As mentioned above, for online services such as Facebook, Twitter, etc. the users (and all the personal information they collect about us) are their main product. They have this absolutely fantastic collection of all sorts of data about people's interests, habits, relationships, etc. and that information is valuable to businesses.
A lot of those services also feature advertising as a source of income.
Open sourced projects such as OGRE don't necessarily make money, or at least don't aim to do so. Possible sources of income (often used to pay for web-hosting, etc. rather than to generate a profit) commonly include advertising and donations. Many of these projects are ran and contributed to by volunteers, and they're simply trying to provide a good piece of software, library of code, or whatever free of charge, often with a certain ideology.
In some cases software or libraries may be free but income is gained from selling support to businesses or individuals who use it.