If a person is staying in a hotel on Shabbat, and the non-Jewish hotel staff brewed coffee for its guests, the majority of whom are not Jewish, may he drink this coffee?
As a general rule, Halacha allows benefitting from a Melacha performed on Shabbat by a non-Jew for a non-Jew, as long as it is clear that no additional Melacha was performed for a Jew. However, the Shulhan Aruch (Orah Haim 325:6) makes an exception when it comes to bread. If a non-Jew bakes bread for himself on Shabbat, even though all the ingredients are kosher, a Jew may not partake of this bread. (The Shulhan Aruch writes that this is permissible only "Bi’she’at Ha’dahak" – under extenuating circumstances.) The question thus arises as to the reason for this exception, and whether it applies to freshly-brewed coffee, as well.
The Mishna Berura (Rav Yisrael Meir Kagan, 1839-1933) brings two reasons for this Halacha. The first reason is that the bread is forbidden because of the rule of "Nolad," which forbids making use of something which came into existence before Shabbat. Bread baked on Shabbat did not exist before Shabbat, as when Shabbat began there was only flour and the other ingredients, and thus the bread is forbidden on Shabbat. The second possibility, which the Mishna Berura cites from the Mordechi, is that since people are drawn after food, the Sages forbade partaking of food prepared on Shabbat by non-Jews for non-Jews. If this were allowed, the Sages feared, then people might then ask non-Jews to prepare food for them on Shabbat, in violation of Halacha.
The Ben Ish Hai (Rav Yosef Haim of Baghdad, 1833-1909) discusses (in Parashat Teruma) the question of how this might affect the status of coffee prepared by gentiles on Shabbat. The context of his discussion is the practice that many Jews in Baghdad had at that time to drink coffee in gentile shops on Shabbat. They would make an arrangement with the shopkeepers before Shabbat to avoid having to pay money on Shabbat, and then enjoy on Shabbat the freshly-brewed coffee which was prepared by the gentile shopkeepers for their predominantly non-Jewish clientele. The Ben Ish Hai writes that as for the first concern, the prohibition of "Nolad," one could argue that coffee, unlike bread, does not fall under this category. After all, coffee is, essentially, flavored water, and the water and coffee beans both existed before Shabbat. Coffee differs in this respect from bread, which is an entirely new entity once it is baked. Therefore, one could certainly contend that coffee brewed on Shabbat should not be forbidden on the grounds of "Nolad." (The Ben Ish Hai draws proof from the fact that we recite "Sha’hakol" on coffee, not "Ha’etz," indicating that Halacha treats coffee essentially as flavored water.) However, the Ben Ish Hai writes, the second concern – that food prepared by gentiles on Shabbat is treated differently than other cases of Melacha performed by gentiles – would, seemingly, apply to coffee just as it does to bread. Just as bread baked on Shabbat is forbidden due to the concern that one might ask a gentile to prepare bread for him on Shabbat, by the same token, coffee should be forbidden out of the concern that one might ask a gentile to brew coffee for him.
Rav Shlomo Miller (contemporary) suggests distinguishing in this regard between food and beverages, proposing that perhaps people are not as drawn after beverages as they are after food. As such, perhaps there is room to permit coffee brewed by non-Jews on Shabbat. However, while this might be true regarding water – such that it would be permissible, for example, to take hot water from an urn turned on by a gentile on Shabbat for other gentiles – it would seem that coffee is no different from food in this regard. Many people very much enjoy – and in fact need – coffee, and thus there is no less concern that people might ask a gentile to brew coffee for them as there is that people might ask a gentile to prepare bread for them.
The Ben Ish Hai concludes that those who drink the coffee in the gentiles’ shops have a basis on which to rely, for, as we saw, according to one view, the determining factor is "Nolad," which does not apply to coffee. However, since according to others there is a special prohibition that applies to food, it is preferable to act stringently in this regard. This is the view accepted also by Hacham Ovadia Yosef, in his Halichot Olam. Therefore, it is preferable not to drink coffee brewed on Shabbat by gentiles, even if this were done for gentiles.
It should be noted that this would not apply to coffee brewed by machines. The concern applies only to food or beverages prepared by a non-Jew on Shabbat; it does not pertain to machines. Therefore – assuming, of course, there are no Kashrut concerns – it would be permissible to drink coffee brewed by an automated machine on Shabbat.
Summary: If a non-Jew brewed coffee on Shabbat for other non-Jews – such as in a hotel serving mainly non-Jewish guests – there is room to allow a Jew to drink this coffee (assuming, of course, there are no Kashrut concerns), though it is preferable not to drink the coffee. However, coffee brewed by an automated machine on Shabbat may be drunk (again, assuming there are no Kashrut concerns).