In Berachot 7a we find the following passage:
וא"ר יוחנן משום ר' יוסי שלשה דברים בקש משה מלפני הקב"ה ונתן לו בקש שתשרה שכינה על ישראל ונתן לו שנאמר הלוא בלכתך עמנו בקש שלא תשרה שכינה על עובדי כוכבים ונתן לו שנאמר ונפלינו אני ועמך בקש להודיעו דרכיו של הקב"ה ונתן לו שנא' הודיעני נא את דרכיך אמר לפניו רבש"ע מפני מה יש צדיק וטוב לו ויש צדיק ורע לו יש רשע וטוב לו ויש רשע ורע לו אמר לו משה צדיק וטוב לו צדיק בן צדיק צדיק ורע לו צדיק בן רשע רשע וטוב לו רשע בן צדיק רשע ורע לו רשע בן רשע אמר מר צדיק וטוב לו צדיק בן צדיק צדיק ורע לו צדיק בן רשע איני והא כתיב פקד עון אבות על בנים וכתיב ובנים לא יומתו על אבות ורמינן קראי אהדדי ומשנינן לא קשיא הא כשאוחזין מעשה אבותיהם בידיהם הא כשאין אוחזין מעשה אבותיהם בידיהם אלא הכי קא"ל צדיק וטוב לו צדיק גמור צדיק ורע לו צדיק שאינו גמור רשע וטוב לו רשע שאינו גמור רשע ורע לו רשע גמור ופליגא דר' מאיר דא"ר מאיר שתים נתנו לו ואחת לא נתנו לו שנא' וחנתי את אשר אחון אע"פ שאינו הגון ורחמתי את אשר ארחם אע"פ שאינו הגון
R. Johanan further said in the name of R. Jose: Three things did Moses ask of the Holy One, blessed be He, and they were granted to him. He asked that the Divine Presence should rest upon Israel, and it was granted to him. For it is said: Is it not in that Thou goest with us [so that we are distinguished, I and Thy people, from all the people that are upon the face of the earth]. He asked that the Divine Presence should not rest upon the idolaters, and it was granted to him. For it is said: 'So that we are distinguished, I and Thy people'. He asked that He should show him the ways of the Holy One, blessed be He, and it was granted to him. For it is said: Show me now Thy ways. Moses said before Him: Lord of the Universe, why is it that some righteous men prosper and others are in adversity, some wicked men prosper and others are in adversity? He replied to him: Moses, the righteous man who prospers is the righteous man the son of a righteous man; the righteous man who is in adversity is a righteous man the son of a wicked man. The wicked man who prospers is a wicked man son of a righteous man; the wicked man who is in adversity is a wicked man son of a wicked man.
The Master said above: 'The righteous man who prospers is a righteous man son of a righteous man; the righteous man who is in adversity is a righteous man son of a wicked man'. But this is not so! For, lo, one verse says: Visiting the iniquity of the fathers upon the children, and another verse says: Neither shall the children be put to death for the fathers. And a contradiction was pointed out between these two verses, and the answer was given that there is no contradiction. The one verse deals with children who continue in the same course as their fathers, and the other verse with children who do not continue in the course of their fathers! — [You must] therefore [say that] the Lord said thus to Moses: A righteous man who prospers is a perfectly righteous man; the righteous man who is in adversity is not a perfectly righteous man. The wicked man who prospers is not a perfectly wicked man; the wicked man who is in adversity is a perfectly wicked man. Now this [saying of R. Johanan] is in opposition to the saying of R. Meir. For R. Meir said: only two [requests] were granted to him, and one was not granted to him. For it is said: And I will be gracious to whom I will be gracious, although he may not deserve it, And I will show mercy on whom I will show mercy, although he may not deserve it.
It seems that there was a dispute among the tannaim as to whether Moses was able to understand the ways of God, particularly about bad things happening to good people and vice versa. R. Yosi claimed that this is something that God explained to him – and two potential explanations are given. R. Meir, though, apparently holds that God did not explain this to Moses. Moses therefore was unable to understand the ways of God in this area, and presumably no other human could as well.
In Kiddushin 39b we are told that the cause of Acher's heresy was that he couldn't understand God's justice:
דתניא רבי יעקב אומר אין לך כל מצוה ומצוה שכתובה בתורה שמתן שכרה בצדה שאין תחיית המתים תלויה בה בכיבוד אב ואם כתיב למען יאריכון ימיך ולמען ייטב לך בשילוח הקן כתיב למען ייטב לך והארכת ימים הרי שאמר לו אביו עלה לבירה והבא לי גוזלות ועלה לבירה ושלח את האם ונטל את הבנים ובחזירתו נפל ומת היכן טובת ימיו של זה והיכן אריכות ימיו של זה אלא למען ייטב לך לעולם שכולו טוב ולמען יאריכון ימיך לעולם שכולו ארוך ודלמא לאו הכי הוה ר' יעקב מעשה חזא ודלמא מהרהר בעבירה הוה מחשבה רעה אין הקב"ה מצרפה למעשה ודלמא מהרהר בעבודת כוכבים הוה וכתיב למען תפוש את בית ישראל בלבם איהו נמי הכי קאמר אי סלקא דעתך שכר מצוה בהאי עלמא אמאי לא אגין מצות עליה כי היכי דלא ליתי לידי הרהור והא א"ר אלעזר שלוחי מצוה אין נזוקין התם בהליכתן שאני והא אמר רבי אלעזר שלוחי מצוה אינן נזוקין לא בהליכתן ולא בחזירתן סולם רעוע הוה דקביע היזיקא וכל היכא דקביע היזיקא לא סמכינן אניסא דכתיב ויאמר שמואל איך אלך ושמע שאול והרגני אמר רב יוסף אילמלי דרשיה אחר להאי קרא כרבי יעקב בר ברתיה לא חטא ואחר מאי הוא איכא דאמרי כי האי גוונא חזא ואיכא דאמרי לישנא דחוצפית המתורגמן חזא דהוה גריר ליה דבר אחר אמר פה שהפיק מרגליות ילחך עפר נפק חטא
For it was taught: R. Jacob said: There is not a single precept in the Torah whose reward is [stated] at its side which is not dependent on the resurrection of the dead. [Thus:] in connection with honouring parents it is written, that thy days may be prolonged, and that it may go well with thee. In reference to the dismissal of the nest it is written, that it may be well with thee, and that thou mayest prolong thy days. Now, if one's father said to him, ‘Ascend to the loft and bring me young birds,’ and he ascends to the loft, dismisses the dam and takes the young, and on his return falls and is killed — where is this man's happiness and where is this man's prolonging of days? But ‘in order that it may be well with thee’, means on the day that is wholly good; and ‘in order that thy days may be long’, on the day that is wholly long.
Yet perhaps there was no such happening? — R. Jacob saw an actual occurrence. Then perhaps he was meditating upon a transgression? — The Holy One, blessed be He, does not combine an evil thought with an [evil] act. Yet perhaps he was meditating idolatry, and it is written, that I may take the house of Israel in their own heart? — That too was precisely his point: should you think that precepts are rewarded in this world, why did the [fulfilment of these] precepts not shield him from being led to [such] meditation?
Yet R. Eleazar said: Those who are engaged on a precept are never harmed? — There, when they are going [to fulfil the precept], it is different. But R. Eleazar said: Those who are engaged on a precept are never harmed, either when going or returning? — It was a rickety ladder, so that injury was likely, and where injury is likely one must not rely on a miracle, for it is written, and Samuel said: How can I go? if Saul hear it, he will kill me.
R. Joseph said: Had Aher interpreted this verse as R. Jacob, his daughter's son, he would not have sinned. Now, what happened with Aher? Some say, he saw something of this nature. Others say, he saw the tongue of Huzpith the Interpreter dragged along by a swine. ‘The mouth that uttered pearls licks the dust!’ he exclaimed. [Thereupon] he went forth and sinned.
Is there a connection between these two passages? Is it just a coincidence that Acher rejected Judaism because of his problems with Divine justice, and his student R. Meir was the one that asserted that it is impossible to understand Divine justice? Or was R. Meir perhaps influenced in some way by what happened to his teacher, and his interpretation in Berachot was a response to that?