Codesharing was sold to the regulators as a way to offer a larger variety and more frequent routes to the customer under the "name" of one airline. This was supposed to be less confusing and more convenient for passengers. Of course we know that is often not the case. The marketing carrier is supposed to be the customers contact and contract/tariff party BUT the airlines were very good at ensuring that the royal-run-around and finger-pointing occurs regularly.
Still, I recently booked an AC flight operated by Lufthansa that would have cost several $thousand more for the same seats on an LH ticket code.