I believe, in part, they make money off code-sharing, revenue-sharing, as well as having exclusive control over certain routes as part of their contract. Keep in mind, for every traveler banking miles with UA, I'm sure there are other flying UA and banking miles with Lufthansa or whatever have you. In grand scheme of things, alliances are there to 'control' a global presence. The more parts of the world you're able to reach, the better chance people will fly with your airline to their final destination. Let's say to get to Doha from Newark, you will probably fly UA into Frankfurt, then Lufthansa into Doha (and I believe both airlines will get a share of the revenue)...everyone wins...sort of.
I'm sure there is MUCH more to this and this is just my $.02