This passage discusses God's attributes and human efforts in prayer and relationship with Him, including the idea of favor and response. It is useful for the distinction between general providence and the special answering of those who seek Him.
אָמַר רַבִּי אֶלְעָזָר, אָמַר לָהֶם הַקָּדוֹשׁ בָּרוּךְ הוּא לְיִשְׂרָאֵל: דְּעוּ כַּמָּה צְדָקוֹת עָשִׂיתִי עִמָּכֶם שֶׁלֹּא כָּעַסְתִּי בִּימֵי בִּלְעָם הָרָשָׁע, שֶׁאִלְמָלֵי כָּעַסְתִּי — לֹא נִשְׁתַּיֵּיר מִשּׂוֹנְאֵיהֶם שֶׁל יִשְׂרָאֵל שָׂרִיד וּפָלִיט. הַהוּא מִינָא דַּהֲוָה בְּשִׁבְבוּתֵיהּ דְּרַבִּי יְהוֹשֻׁעַ בֶּן לֵוִי, הֲוָה קָא מְצַעֵר לֵיהּ טוּבָא בִּקְרָאֵי. יוֹמָא חַד שְׁקַל תַּרְנְגוֹלָא, וְאוֹקְמֵיהּ בֵּין כַּרְעֵיהּ דְּעַרְסָא, וְעַיֵּין בֵּיהּ, סְבַר: כִּי מָטָא הַהִיא שַׁעְתָּא, אֶלְטְיֵיהּ. כִּי מְטָא הַהִיא שַׁעְתָּא — נָיֵים. אֲמַר: שְׁמַע מִינַּהּ, לָאו אוֹרַח אַרְעָא לְמֶעְבַּד הָכִי. ״וְרַחֲמָיו עַל כָּל מַעֲשָׂיו״ כְּתִיב.
Rabbi Elazar said that the Holy One, Blessed be He, said to Israel: Know how many acts of kindness I performed on your behalf, that I did not become angry during the days of Balaam the wicked, for had I become angry, there would have been no remnant or survivor remaining among the enemies of Israel, a euphemism for Israel itself. Instead, God restrained His anger and Balaam’s curse went unfulfilled. The Gemara relates: A certain heretic who was in Rabbi Yehoshua ben Levi’s neighborhood would upset him by incessantly challenging the legitimacy of verses. One day, Rabbi Yehoshua ben Levi took a rooster and placed it between the legs of the bed upon which he sat and looked at it. He thought: When the moment of God’s anger arrives, I will curse him and be rid of him. When the moment of God’s anger arrived, Rabbi Yehoshua ben Levi slept. When he woke up, he said to himself: Conclude from the fact that I nodded off that it is not proper conduct to do so, to curse people, even if they are wicked. “His mercy is over all His creations” (Psalms 145:9) is written even with regard to sinners.