To answer in a little more detail if you're interested:
1) Every time that points are added to your account, someone is paying for it. For Qantas restaurants that award 3 points per $1 spent, they are charged a fee of 6% of the purchase value (which means they are essentially 'buying' points for 2c each). In a similar way, credit card companies are also charged a fee per point that they buy, though they obviously pay a much more competitive rate. The same applies for airlines, who typically award points based on the number of miles flown. As the airline that the passenger is flying on has to pay for the points, you'll find that some (eg. Cathay Pacific) award NO points at all on the cheapest fares, as there is no real margin to do so at that price. Others (eg. British Airways) do still award points on the cheap fares, though at 1/4 of the earn rate of a more expensive ticket. The frequent flyer program essentially gets to sit on these funds (or reinvest them etc) while you have a positive points balance. When you go to redeem these points, you pay essentially 'pay' with points, but in the background, the FF program is paying the supplier in cash - usually at a cheaper bulk/industry discount rate. The gross profit made is the difference between the financial income from their earning partners that are buying points (eg other airlines, credit card companies etc), and the amount of money that they spend on funding award redemptions.
2) Codeshares usually take place in one of two ways. The first, is that the codeshare partner 'buys' a specific number of physical seats on that flight, and it is up to them to sell those seats. In this situation, the codeshare partner (such as South African Airways) could buy themselves, say, 10 seats on the QF SYD-JNB (Johannesburg) service, using the SAA flight code. As these seats 'belong' to SAA, QF cannot sell them themselves. If SAA sell a certain percentage of these seats on their code, they make a profit, as the amount received for the seats will be more than the amount paid to QF. If SAA don't sell enough, they make a loss on that flight, as they will be paying for seats that nobody is travelling in. Provisions may be made between the airlines that the operating carrier may sell those seats within a certain number of hours before departure, though even if that's not the case, they are almost certainly then available to standby passengers that have booked directly with Qantas. QF would then earn twice - the fixed payment from SAA, and then being paid to fill the seats themselves. Alternately, codeshare seating may be flexible, in that each airline can sell as many or as few seats on the plane as they are able (though some limits may be applied). This allows an airline to put their code on a flight without taking too much of a financial risk - as the operating carrier is simply receiving extra passengers in order to fill up seats. While this model would benefit a codeshare partner if demand was light, the profit margin is likely lower than the 'fixed' codesharing model.
3) Alliances exist not just for lounge access benefits, but also usually simplify a set of rules across the alliance (eg. baggage interlining and transit passengers). They make it much easier for one airline to get their passengers to a final destination that the airline doesn't fly to (such as Qantas Sydney-Hong Kong, connecting to Cathay Pacific Hong Kong-Beijing), as they can easily sell this on the one ticket, and usually issue the boarding passes when the customer checks in for their first flight, as well as check their luggage through to their final destination. While this is of course all possible without a formal alliance, it makes it much more simplified. There are a great number of other aspects involved that I won't go into, but alliances are a two-way street. For example, if an American Airlines Executive Platinum passenger is flying with Qantas, Qantas benefits as they will receive payment from AA when that passenger accesses one of their lounges using their AA membership. Then once the passenger has completed their flight, Qantas then 'purchase' the AA miles for that customer, which takes us back to question 1!
Note: the info above is all available publicly, I have merely collated it (I was interested in the same thing myself not too long ago). As to exact payment figures for the various activities (besides the charges for QFF restaurant partners), this would be commercially sensitive information, to which I'm not privy (I don't work for the airlines, so I only know what is available online).
