It's usually set out by contract between the airlines. The FFP buys a seat at a negotiated rate from the partner airline, and gets to write the value of the miles off their books. Any difference is either a profit (value of the miles exceeds cost of the flight) or a book loss (value of the miles isn't enough to pay for the flight).
Overall the plans tend to turn a profit, because if redemptions are costing too much, the airline can capacity control "saver" awards and encourage double mile rule-buster awards. And redemptions between similarly sized airlines tend to offset- CO miles used to redeem NW flights are usually about equal to NW miles used to redeem CO flights.