The commandment to judge favorably comes from the verse "בְּצֶ֖דֶק תִּשְׁפֹּ֥ט עֲמִיתֶֽךָ". Sefer Hachinuch and others say that this refers to the necessity to judge "your fellow" favorably.
However, anyplace where it says "אחיך" or "עמיתך" the Torah refers to those Jews who keep the Torah, and have not purposely "thrown off the yoke of heaven," (see the Chafetz Chaim for how this applies to Lashon Hara, which has very similar laws). Thus, the commandment to judge favorably only applies to Jews who are considered "your fellow." Additionally, the commandment is not to judge them favorably, but rather to judge them "with justice," meaning that you must judge them according to their actions, whether they have a history of wickedness or righteousness, etc.
However, when the Sages in Ethics of the Fathers say, "Judge every man favorably," this is only a "middas chassidus:" it is recommended, but by no means required, to judge someone whose previous actions are unknown favorably.
Havig an ayin tova, though, is less about halacha and more about a way of life. In order to see the good in G-d's creations and other people, especially those who you must see the good in, it is recommended to think this way about everyone. The Chafetz Chaim says that, while one is allowed to speak Lashon Hara about a non-Jew, it is not a good idea, because it trains one's mind to think negatively about people in general, which can lead to transgression. In order to be in the habit of thinking positively, one should refrain from judging negatively when it is not necessary.