Codesharing was invented for that very purpose. It allows an airline to sell, among other things, a domestic network in a foreign country that it cannot fly for obvious reasons. Codeshares greatly simplify the ticketing process for customers and at least imply that the ticket issuer has confidence in the operating carrier.