Answer: The Gemara in Masechet Sotah (2a) states: “Reish Lakish said: A man is only paired with a woman based on his actions, as the verse states (Tehillim 125), ‘For the scepter of the wicked shall not rest upon the allotted plot of the righteous’ (meaning that a bad match will not be destined for a good person).” The Gemara asks on this statement made by Reish Lakish that Rav Yehuda said in the name of Rav that forty days before a fetus is formed, a Heavenly voice rings out and says, “The daughter of so-and-so is destined to marry so-and-so (this fetus).” If so, how could Reish Lakish say that one’s match is based on his deeds and actions, it seems that it is merely a Heavenly decree? The Gemara answers that one’s first marriage match is based on a Heavenly decree regardless of one’s actions, but one’s second marriage match is based solely on one’s actions.
Indeed, even one’s first marriage match is somewhat based on one’s deeds. Hagaon Harav Tuvia Ha’Levi (who resided in Tzefat approximately four-hundred years ago) explains that when the Gemara says that one’s first marriage match is decided by virtue of a Heavenly decree, that even if both spouses are not completely equal in their actions, neither completely righteous nor completely wicked, rather, if they are righteous, one is more righteous than the other and if they are wicked, one is more wicked than the other, they will nevertheless get married, for this was decreed by Hashem and announced by the Heavenly voice. However, if they are very far from each other on a spiritual level, i.e. a completely righteous man with a completely wicked woman and vice versa, the decree will be annulled and they will be judged based on their actions. When the Gemara says that one’s second marriage match is determined based on one’s actions, this means that one is judged with precision to ensure that they are both truly equal with regards to righteousness or wickedness. There are many other things which are brought down that may cause one’s prospective marriage match to change for better or worse, but one’s deeds and prayers can indeed cause one to merit an excellent match.
Nevertheless, when one searches for a prospective spouse, one must intend to do so for the sake of Heaven and search for a spouse appropriate for him and not put forth exaggerated or irrational requirements which may cause one to lose out.
There is a well-known incident involving Hagaon Harav Meshulam Igra zt”l (who lived approximately two-hundred years ago). Although he lived a life of poverty and oppression, he merited delving diligently in the Torah and was considered a genius and a righteous young man. The wealthy Rabbi Shmuel Bick took him as a husband for his only daughter. After they were married, his wife saw that her husband did not understand worldly matters very much since he was always completely involved in spiritual matters. She was not pleased with this and she requested a divorce. Her father also intervened on her behalf when he saw that his only daughter was unhappy. With a heavy and aching heart, Hagaon Harav Meshulam acquiesced and divorced her with a Get as she and her father had requested.
At approximately the same time, a great disagreement arose among the greatest luminaries of Brody regarding the validity of a certain Get (Bill of Divorce). They decided that Hagaon Harav Yeshaya Berlin, Chief Rabbi of Breslevi, would decide on the matter since he was a tremendous genius and was fluent with rulings of the Rishonim and Acharonim on many matters. The question was sent to him along with the opinions of several rabbis who validated the Get as well as those who invalidated it. Among the rabbis who wrote on the matter was Hagaon Harav Meshulam Igra who included his opinion on the matter.
As Hagaon Harav Berlin was looking over the responsa before him, Rabbi Shmuel Bick, the wealthy businessman from Brody, arrived in Breslevi and went to visit Harav Berlin, who was a longtime acquaintance of his. As he was reading through the letter of Hagaon Harav Meshulam Igra, Hagaon Harav Berlin asked Rabbi Bick if he knew of this Harav Meshulam Igra. Rabbi Bick replied that he indeed knew of him and said that he was a mere young man of seventeen. Hagaon Harav Yeshaya Berlin expressed his amazement that this individual was so young but showed such vast knowledge and genius just like the greatest luminaries of the generation. Upon hearing these words uttered by the elderly Torah giant, Rabbi Bick gasped and fainted. Hagaon Harav Berlin called for help and water was splashed on him until he was revived. Harav Berlin then asked him why he fainted. Rabbi Shmuel Bick replied, “This young man was once my son-in-law and was unfortunately convinced to divorce my daughter based on my request.” Harav Yeshaya Berlin then told him, “If this young Torah genius was in your home and you chased him out, you must indeed faint again!” Not long after, Hagaon Harav Meshulam Igra merited marrying the daughter of Hagaon Harav Yitzchak Horowitz, Chief Rabbi of Brody, and lived a happy and fulfilling life with her.