Idolators are enemies of God, which makes them our enemies. If we do not have the ability to drive them out or eradicate their idols, we may have to co-exist with them, but that doesn't make us their friends. This mitzvah forbids us from complimenting and flattering idolators, or from giving them gifts as a token of our esteem.
The reason underlying this mitzvah is that our words are but the first step. What we say is followed in short order by what we do and what we believe. First we'll be all, "I like your Baal-worshipping robe," and before you know it, our idolatrous neighbor is telling us all about Baal and taking us to his temple. There's no potential benefit to this chain of events, so why even get started?
This mitzvah applies in all times and places. It is discussed in the Talmud in tractate Avodah Zarah (20a). It is codified in the Mishneh Torah in the tenth chapter of Hilchos Avodas Kochavim. This mitzvah is #50 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos and #20 of the 194 negative mitzvos that can be observed today as listed in the Chofetz Chaim’s Sefer HaMitzvos HaKatzar.