A forum is no different from other websites in this regard. It can make money by showing advertisements, by providing affiliate links, by selling a product, or similar ways.
Not all forums exist simply to make money. Some companies set up forums as a vehicle for supporting their products, or simply to promote discussion. But the above methods can still be useful, if only to pay the development and hosting costs.
As for how much a forum can make, that would depend on the number of members, the subject matter of the forum, and on how hard the site owners are prepared to work at it.