The Gemoro Shabbos 127b brings three stories illustrating the principle,
הדן חבירו לכף זכות דנין אותו לזכות
“He who judges his neighbour in the scale of merit is himself judged favourably.”
The stories show how one person (Reuven) took certain actions which could be interpreted well or badly by another (Shimon). Shimon, despite his personal disadvantage, interpreted the actions in a positive light. Reuven blessed Shimon that just as Shimon judged him favourably, so G-d should judge Shimon favourably.
The problem is that in the stories, Shimon did not know the truth and made a decision that Reuven had acted well. When G-d judges, He knows all the truth, so how can it be that He can judge Shimon favourably?