It says in Tehillim 90 (a chapter attributed to Moshe Rabbeinu, if that affects anything):

יא: מִֽי־י֖וֹדֵעַ עֹ֥ז אַפֶּ֑ךָ וּ֜כְיִרְאָֽתְךָ֗ עֶבְרָתֶֽךָ: לִמְנ֣וֹת
יָ֖מֵינוּ כֵּ֥ן הוֹדַ֑ע וְ֜נָבִ֗א לְבַ֣ב חָכְמָֽה: 11 Who knows the
might of Your wrath, and according to Your fear is Your anger. 12
So teach the number of our days, so that we shall acquire a heart of
wisdom.

I saw in another translation: "According to the fear of You is Your anger."

I was trying to find out what all this means and saw the following gemara (Taanit 8a or thereabout) :

§ Rabbi Yoḥanan said: Whoever is exacting with himself, by striving to
act righteously in every way on earth below, he is judged in an exact
manner in Heaven above, in order to improve him further still, as it
is stated: “Truth springs out of the earth, and righteousness has
looked down from heaven” (Psalms 85:12). Rabbi Ḥiyya bar Avin said
that Rav Huna said that this idea is derived from here: “And Your
wrath is according to the fear that is due to You” (Psalms 90:11). The
level of God’s wrath correlates with the offender’s fear of God.

Reish Lakish said that this principle is derived from here: “You took
him away who joyfully performed righteousness, those who remembered
You in Your ways, behold You were wroth, and we sinned, upon them have
we stayed of old, that we might be saved” (Isaiah 64:4). This verse
also teaches that God displays wrath specifically due to the
transgressions of those who are accustomed to acting righteously.

This is all very difficult to swallow. It seems to say that one who sins only occasionally is punished more harshly for his sins than one who sins frequently. How does it not fly in the face of the entire reward and punishment doctrine? (Is it suggesting, for example, that one is still rewarded for increasing observance, but with diminishing returns?)

We have a mitzvah to fear G-d at all times, said Rambam or maybe Rashi. But the assertion that "the level of God’s wrath correlates with the offender’s fear of God" is hardly encouraging in this matter. (How can we give our utmost in this mitzvah anyway?)

Finally, how does this all square up with the known idea (again I can't find the source, but I am quite sure it exists in Chasidus Chabad if not elsewhere--I think it is the primary thought underlying the over-the-top efforts we make for Pesach, for example) that one endeavors to go beyond the letter of the Law precisely out of love and gratefulness to G-d for His own chesed in dealing with us? It seems quite backwards that we should set ourselves up to incur punishment if G-d forbid we fell short of our ambitions.

R. Abba stated: His son nevertheless died of thirst; for it is said in
Scripture, And round about Him it stormeth mightily, which teaches
that the Holy One, blessed be He, deals strictly with those round
about Him even to a hair's breadth. R. Hanina said, [Proof may be
adduced] from here: A God dreaded in the great council of the holy
ones, and feared of all them that are round about Him. (Soncino translation)

And repayeth them that hate Him to His face, to destroy him. R. Joshua
b. Levi remarked: Were it not for the written text one could not
possibly have said it. Like a man, as it were, who carries a burden on
his face and wants to throw it off. He will not be slack to him that
hateth Him. R. Il'a explained: He will not be slack to those that hate
Him, but He will be slack to those who are just in all respects; and
this is in line with that which R. Joshua b. Levi stated: What [is the
implication of] what was written: Which I command thee this day to do
them? ‘This day [you are] to do them’ but you cannot postpone doing
them for tomorrow; ‘this day [you are in a position] to do them’ and
tomorrow [is reserved] for receiving reward for [doing] them.

R. Haggai (or as some say: R. Samuel b. Nahmani) stated: What [was the
purpose] when Scripture wrote: Long-suffering [in the dual form] where
the singular might well have been used? But [this is the purport:]
Long-suffering towards the righteous and long-suffering also towards
the wicked. (Soncino translation)

As explained by Rashi and Tosafot, this means that God saves the punishment of the wicked and the reward of the righteous for the next world – and the implication is that the righteous receive their (whatever minute amount of) punishment and the wicked receive their (whatever minute amount of) reward in this world.

Raba (some say, R. Hisda) says: If a man sees that painful sufferings
visit him, let him examine his conduct. For it is said: Let us search
and try our ways, and return unto the Lord. If he examines and finds
nothing [objectionable], let him attribute it to the neglect of the
study of the Torah. For it is said: Happy is the man whom Thou
chastenest, O Lord, and teachest out of Thy law. If he did attribute
it [thus], and still did not find [this to be the cause], let him be
sure that these are chastenings of love. For it is said: For whom the
Lord loveth He correcteth.

Raba, in the name of R. Sahorah, in the
name of R. Huna, says: If the Holy One, blessed be He, is pleased with
a man, he crushes him with painful sufferings. For it is said: And the
Lord was pleased with [him, hence] he crushed him by disease. Now, you
might think that this is so even if he did not accept them with love.
Therefore it is said: To see if his soul would offer itself in
restitution. Even as the trespass-offering must be brought by consent,
so also the sufferings must be endured with consent. And if he did
accept them, what is his reward? He will see his seed, prolong his
days. And more than that, his knowledge [of the Torah] will endure
with him. For it is said: The purpose of the Lord will prosper in his
hand. (Soncino translation)

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. (Soncino translation)

In short, to whatever extent we can understand the workings of God, the seemingly harsh punishments meted out to the righteous are for good reason.

This is a fascinating answer; thank you. I am still waiting for insights on this topic that would explain why a non-tzaddik should still want to be righteous despite the "fact" (??) that it will get him punished here on earth. (It is very hard to hold out for the rewards of the Next World, or entirely to subjugate one's self-interest to the Will of the Creator -- though of course that is the goal.)
– SAHAug 16 '18 at 22:36

1

I don't have a source for this but basically texts dealing with this suggest that the closer you draw to Him the greater the reward for your mitzvot (in this world for some, Olam Haba for others, depends on the mitzvah) but also the greater the punishment for your transgressions.
– Josh KAug 17 '18 at 6:03