If it's to make the passenger believe a company can take you anywhere it is silly as you'll see it is not the case as soon as you enter the plane.
If it's the result of an alliance between two companies, fine but why not codeshare all the flights of the other company?
In any case I used to find it very frustrating to think I was flying with a company and then finding I am actually flying with another I may not be interested in. Now I always check what is the company obviously.
So what are your thoughts about codeshare?