839 is JFK-LAX-SYD, and 840 is the return. I am assuming they do this for the same reason that 875/876 goes DEN-SEA-NRT, 881/882 BOS-ORD-NRT, etc. It allows them to market service from a non-hub to another. If you were an average random flyer purchasing from Travelocity, etc, you might choose United because you can fly 839 JFK-LAX-SYD, and "avoid" the complication of flying AA JFK-LAX and QF LAX-SYD. Now, we all know that this simply isnt true, and through flights are, with very few exceptions, close to the worst thing ever (exceptions may include LAX-NRT-SIN, whose GCD is nearly identical to n/s distance). This is all about marketing, and its a way for airlines to perhaps gain a small advantage over the uninformed.
Edit: As noted above, it is also aoften a way to offer 3-class service to customers, but since it only works hub-to-hub and west coast to JFK, it only works to a certain extent.