It depends on many factors, but the top three are:
1. load (percentage of seats that are taken)
2. yield (percentage of passengers that are paying higher fares)
3. cargo (sometimes a passenger flight that is unprofitable becomes profitable if there is high-yield cargo on board)