codeshare flights are set up based on the "demand" there would be for such flights. That is why you will see codeshare to some destinations but not to others. As far as AC getting a better deal out of it AC does not keep the revenue they make off the codeshare flights they get a sort of commission and UA gets the rest. It works like that the other way around also.