The problem with buying Yahoo is all the other crap you would get along with search and ads. If Apple were to buy Yahoo and then gut all the other services they offer they would be the bad guy, but I also don't think they would want it all on their balance sheet.
Maybe they could do a deal for a stake in Yahoo in return for a search deal but it would probably require that Yahoo not get into bed with Microsoft like they are planning. I don't think the Yahoo management has the gumption to make a play like that.