Much of the motivation is probably for PR, but it can also be practical. Data centers consume large amounts of power and generate large amounts of heat, and lowering the cost of either obviously benefits the company. I’ve seen servers from a local university used to provide heat for a conservatory. It’s a win for everyone: the conservatory cuts it’s heating bills, the university eliminates the cooling cost associated with those servers, and there is a nice sign to tell the public about this use of the servers, so it also serves as an educational/public relations opportunity for the both institutions.
Facebook has placed some of it’s data centers in very cold climates, such as Finland. Again, this result in both significant savings in cooling costs, but it is also a legitimately helpful “green” decision. Google has invested in wind energy. Sure, some of that is for the publicity and to differentiate themselves from their competitors, but I am certain that the company has done enough cost projections to realize that renewable energy can be comparable to conventional energy sources. Plus, the investment in renewables by these large companies helps renewable energy become more viable, and over time should help lower the cost of renewable energy.