The Ramban shares a tremendous yesod. It is not within the power of the righteous for their Tefillah on behalf of others to automatically be heard and answered. Hakadosh Baruch Hu wants to hear from the affected person directly. When Rachel attempted to frighten him with the proposition of her death, it sparked a response that he is not in G-d’s place and that the withholding of children is not due to him but rather to her. He said this to admonish her, so that the righteous Rachel would realize she could not rely on Yaakov’s Tefillah and would need to daven for herself. And she did just that, which is why it later says, ִשְׁמַע אֵלֶיהָ אֱ וַי-ל ֹהִ ים – Hakadosh Baruch Hu heard her.
The Kli Yakar adds another explanation. Yaakov himself was unsure whether Hakadosh Baruch Hu would accept his Tefillah, because sin can sometimes create a barrier that prevents it from being heard. When one's Tefillah is accepted, nothing stands between them and Hakadosh Baruch Hu. However, when not answered, it is as if there’s a screen or cloud that separates the person from Hashem, as it is written (Eichah 3:44): ָה מֵעֲבוֹר תְּפִל סַכּוֹתָה בֶעָנָן לָך. This cloud is the dark matter, the consequences of sin, that prevents prayers from being heard. Upon indicating this fear to Rachel, she reflected on her actions to identify any potential sin, and she realized that it was her jealousy – וַ תְּ קַ נֵּא רָ חֵ ל בַּ אֲ חֹתָ הּ – that caused her prayers to go unanswered. She concluded that this sin had blocked Yaakov’s Tefillah from being heard. Therefore, Rachel made a commitment to do Teshuva for her jealousy, and to correct her behavior. Since she had been jealous of her sister, she would now go to the opposite extreme of advocating that even her maidservant bear children with Yaakov. Rachel believed that by allowing her maidservant to bear children for her, she would rectify the wrong and allow for her Tefillot to be answered. Rachel immediately acted upon these words, davening to Hakadosh Baruch Hu and giving her maidservant Bilhah to Yaakov as a wife; and Bilhah had a son right away. Rachel responded:
וַתּ ֹאמֶ ר רָ חֵ ל דָּ נַנִּי אֱ -ִתֶּן־לִי בֵּן עַל־כֵּן קָרְ אָה שְׁ מוֹ דָּן׃ לֹהִים וְגַם שׁ ָמַע בְּקֹלִי וַי
Rachel said, G-d has judged me. He has also heard my voice and has given me a son. She therefore named him Dan.
Targum Onkelos interprets this statement to mean, “Hashem has judged me and has also accepted my Tefillah, and He gave me a son.” Bilhah then gave birth to a second son, and Rachel named him Naftali. In naming him Naftali, she said: “With divine struggle, I have struggled with my sister, and I have also prevailed.” Onkelos interprets this to mean, “Hashem accepted my request, when I pleaded in my prayer; I desired that I would have children like my sister, and it was also given to me.” Rashi adds an interpretation of נַפְתּ וּלֵי as referring to fervent prayer, indicating that Rachel's heartfelt Tefillot were accepted by Hakadosh Baruch Hu. By naming both of these sons, Dan and Naftali, after her Tefillot, Rachel Imenu teaches us the profound power of Tefillah.
Chazal teach us (Pesikta Rabbati 43:5) that Hakadosh Baruch Hu tests the righteous according to their abilities. For example, Sarah was barren for 25 years after coming to Eretz Yisrael. She gave birth to Yitzchak at age 90, after being tested for 25 years, according to her strength. Similarly, Rivka was barren, and tested, for 20 years. Chana was also tested according to her ability. Chazal explain that her barrenness lasted 19 years, including while Elkana’s second wife, Penina, gave birth to 10 sons. Only afterwards did their perseverance and Tefillot result in children.
The Midrash (Yalkut Shimoni, Shmuel I. 77) says that Tefillah is equivalent to all the Korbanot. Elkanah and his family would travel to Shiloh for the festivals and when asked where they were going, they’d invite the townspeople to join them in ascending to the Mishkan. Their words moved the people, and gradually, more families joined each year. Elkanah even varied his routes to inspire the entire nation to ascend. Hakadosh Baruch Hu said to him, “You have led Am Yisrael to merit, so I will bring forth a son from you who will guide Bnei Yisrael.” It was in Elkanah's merit that Shmuel was born. But to merit a son like Shmuel HaNavi, who was equivalent to Moshe and Aharon, it also required filling cups with tears. When Penina saw that Chana had despaired and had stopped crying, what did she do?
כַּ עַ ס בַּ עֲבוּר הַ רְּ עִ מָ הּ ַם וְ כִ עֲסַ תָּ ה צָרָ תָ הּ ג – She taunted her repeatedly through references to her own children, in order to draw anger. Penina provoked Chana intentionally to make her cry more! This is just like the case of Leah, the mother of six tribes, where it took the shedding of eyelashes from endless tears.
What changed after 19 years of barrenness? The Gemara (Berachot 31b) says, Chana’s Tefillot intensified. And why did she begin to daven with such intensity? Rav Shmuel Truvitz in Ma’adanei Shmuel explains: Until now, Chana relied on her husband’s faith and prayers. She assumed Elkanah had not accepted her barrenness and believed his prayers would secure Hakadosh Baruch Hu’s response even if her own merits were insufficient. However, when Elkanah said, “Am I not better to you than ten sons?" it became clear he had accepted her condition and gave up on davening for change. His words, meant to comfort, sparked her to take matters into her own hands through her own heartfelt Tefillah. And that is exactly what Hakadosh Baruch Hu wanted – to talk to Chanah, directly, in private.
Sometimes we fail to grasp the message that Hakadosh Baruch Hu wants to speak with us. He gives and gives, but we don’t notice. Only when something is taken away do we cry out, "Ribbono Shel Olam, what happened?" His response is very simply: "I only wanted to remind you that I’m here."