Their duty to the stockholders is to do what's in the best interest of the company. It's not a breach of duty for a company to forego short-term profits if, in the management's judgement, those short-term profits can only be had by damaging the company's long-term prospects.
Google stands to make the most money in the long run by being the preferred search engine for the most people. Right now, they are. But that could change if another search engine can convince people they deliver results with less spam.