Devarim 32:4
הַצּוּר תָמִים פָעֳלוֹ כִּי כָל-דְּרָכָיו מִשְׁפָּט אֵ-ל אֱמוּנָה וְאֵין עָוֶל צַדִּיק וְיָשָׁר הוּא
Rashi
Though He is powerful like a Rock, His acts of retribution are perfectly balanced, for all His ways are just; G-d is faithful to reward the righteous ones in the next world and He even rewards the wicked in this world without injustice; all acknowledge that He is righteous and upright in judgment.
Onkelus
The verse makes a statement and the reason follows; the Rock that His work is complete for the sake of all His ways are just. He is faithful to those He deals with since He is righteous and direct.
Daas Yonasan
When Moshe ascended to the heavens he saw that HaShem split His activities into four parts of the day. During the first He is involved in Torah study, the second in judgment, the third in matching up people for marriage (and deciding whom to elevate and whom to lower), and the fourth He is involved in supplying sustenance to all His creations.
These four points are alluded to in the four sections of our verse.
(1) "Tomim" refers to the Torah, which is called "t'mimoh." (2) "Ki chol drochov mishpot" clearly indicates judgment. (3) "V'ein o'vel" refers to properly matching up couples, as per the Gemara Sotah 2a, that people are matched up with whom they deserve, based on their behaviour. (4) "Tzadik" refers to one who sustains the world, as we find that Noach is called "tzadik" and he sustained all the creatures in the ark. Yoseif is likewise called "tzadik," and he also sustained Egypt and the surrounding countries. Hashem is also called "Tzadik" in relation to His sustaining the world, as per the verse in Tehillim 145, "Po'sei'ach es yo'decho umasbia l'chol chai rotzone, "TZADIK HaShem."
Torah Shlemah
A Jewish custom is that when a Jew dies, we speak of the righteous judgment of G-d by saying "HaTzur tomim po'olo". This is a very old custom based on the Gemara (Avodah Zara 18a) The Roman authorities charged R. Chanina ben Tradyon 'why did you engage in Torah?' R. Chanina answered that HaShem commanded me to do so. It was decreed that he be burned, for he used the letters of HaShem's name (Rashi - he expounded them; Tosfos - he pronounced His name as it is written). When he was taken out for his punishment, Rabbi Chanina justified HaShem's decree saying "Ha'Tzur Tamim Pa'alo..." Explanation of this action is that the Judge of the world is called Tzur, a rock, a substance that became very hard. Similarly, when HaShem becomes a Judge due to our sins, the Merciful G-d has now turned from mercy to strict judgment.
Rabbi Bachaye
Moshe alludes to the creation of Adom haRishon and his sin and punishment. His actions caused pain (צר) to the world. Originally HaShem created Adam that all his work would to be perfect and serve HaShem. Due to his sin which resulted in the punishments since all of HaShem’s ways are proper judgment; G-d is faithful that He exists while the generations of people change; He is righteous and upright.
Rabbenu Efraim
Relationship between צור (rock) and צייר (artist). HaShem is the ultimate Artist, the creator of a wonderful and beautiful universe.
Gr”a
This verse alludes to the three main items creation: עש"ן עולם, שנה, נפש -.
"HaTzur tomim po'olo" – time: prior to creation nothing was lacking.
“Kel emunah” – soul; faithful to revive the dead.
"V'ein o'vel" – world: place where all His Ways are recognized.
Yalkut Meam Loeiz
The Gemara Berachos 7a discusses the subject of "tzadik v'ra lo," why seemingly bad things happen to good people. HaShem imparted of His wisdom to Moshe and allowed him to understand HaShem's ways of justice that He is never unfair. Others do not comprehend this. This subject is on the minds of many. It is related that two people came to the Ibn Ezra with a monetary dispute, and once they were there they also asked this question, not only posing it as a question, but with their intonations indicating that they had a great complaint against HaShem for such seeming injustice. Their monetary question was as follows: They had been traveling together and sat down to eat. Another traveler came upon them and told them that he had no food with him and that he was starving. He told them that he did have money with him and would pay them for whatever they would give him. They agreed to his offer. One of these two had three loaves of bread, while the other had two. All loaves were the same size. They equally consumed all the bread. The man who had no food left them with five gold coins. The person who owned the three loaves felt that he deserved three coins, as he had started off with three loaves and that his friend deserved two coins, as he owned two loaves. His friend disagreed, stating that since the third party consumed an equal amount from both of their breads, he and his friend should each receive 2 ½ coins. The Ibn Ezra ruled that the owner of the three loaves deserves four coins, while the owner of the two loaves deserves only one coin. Both of the litigants responded that the Ibn Ezra does not know how to rule properly, as he awarded one of the men even more than he felt he deserved. The Ibn Ezra explained his position quite simply. Since each of the three people who had partaken of the breads ate an equal amount, let us calculate as follows: The five breads can be considered as 15 portions if we split each loaf into three. Each of the three people ate five portions. The owner of the three breads owned 9 portions while the owner of the two breads owned 6 portions. The owner of the 9 portions ate five portions and gave away 4 portions, while the owner of the 6 portions ate 5 portions and gave away only 1 portion. It thus makes perfect sense to give 4 coins to the owner of the three breads and only 1 coin to the owner of the two breads. The Ibn Ezra ended by telling these two people that if they could not fathom the judgment of a mere flesh and blood human being whose judgment was actually quite simple to comprehend, how could they expect to understand the depth of HaShem's rightful judgment, let alone voice a complaint against HaShem. "Mish'p'tei HaShem emes tzodku yachdov" (Tehillim 19:10).
Rabbi Shimon of Yarislov
He lived to a very old age. He was asked the question "Ba'meh he'erachto yomim" (see Gemara Taanis 20b, Megilah 27b, 28a, Sotah 39a) - what did you do to deserve to live to such a ripe old age? He answered that he never once complained about anything that HaShem did to him. This was because he was absolutely convinced that all that HaShem did to him was deserved and calculated. He continued: "When a person questions HaShem's actions and complains, he is given an answer. However, to comprehend the answer he must be removed from this beclouded and confusing world to see the truth. This necessitates bringing him to heaven, i.e. dying, and showing him the fairness of all that has been meted out to him."
