It states (19:15) עמיתך תשפוט בצדק, "With righteousness, you shall judge your fellow." Rashi explains (in his second explanation) that this means you should judge your fellow man favorably, l'kaf zechus. When your fellow man does something that appears like an aveirah, you are obligated to give him the benefit of the doubt and to assume that it wasn't an aveirah.
The Chinuch (235) writes, "It is proper that every person should judge his friend favorably and interpret his actions and words favorably. This will increase peace and friendship among people... and remove suspicion from one another."
The Kedushas Levi (Shoftim) writes, "When we act with kindness and judge every Yid זכות לכף, favorably, this rouses the same attribute in heaven, and Hashem judges us favorably. This is the translation of the pasuk, לך תתן ושוטרים שופטים; this means you should prepare the judgment of heaven... את ושפטו צדק משפט העם, by judging your fellow man favorably... Because the way a person acts to others is how Heaven will act with him."
