The Midrash says (Shir Hashirim Rabbah 1), “Whoever teaches Torah in public merits Divine inspiration.” Shlomo learned Torah and received Divine inspiration, which enabled him to produce the three great works: Mishlei, Kohelet, and Shir Hashirim.
The Pele Yoetz (Mezakeh) relates that there are numerous methods of bringing merit to others. One is in the realm of Torah: for instance, teaching the nation wisdom, yirat Shamayim, and the proper way to behave. There are those who deliver mussar lectures to the public and constantly fortify them in mitzvah performance. One day, their efforts might bear fruit, if not for a hundred people, then maybe for ten, and if not for ten, then maybe for one.
How wonderful it is to write a sefer containing a synopsis of halachic rulings and proper conduct, or to translate such a work into a familiar language. One engaged in this practice is literally speaking to tens of thousands of our people. Maybe, some generations down the line, a Jew might pick up this sefer and take its message to heart. The writer will have brought merit to this man… The Abarbanel (Devarim 29) writes that man cannot conquer with force, but can only convince with the power of his tongue.
Every person, not only the wise man, is enjoined to rebuke others for their wrongdoings. As the Navi Yeshayahu (41:6) proclaims, “Each man would help his fellow and to his brother he would say, ‘Be strong!’” Let us embolden ourselves in order to bring satisfaction to our Creator. Reward for the one who brings others to do mitzvot is commensurate with the greatness of the mitzvah. One who stands before a gathering, be it in the forum of a lecture or at a meal, and says divrei Torah, is considered to bring merit to the public. One who attempts to establish good practices in his community, such as establishing a fund for the needy, is considered bringing merit to the public, as well.
In short, whoever can prevent others from sinning, encourage others to pursue mitzvot, or serve as a role model for proper behavior is considered to bring merit to the public.
The Chovot Halevavot (Sha’ar Avodat Hashem 6) writes: My brothers, you must know that the merit of the believer, even if he succeeded in reaching the ultimate level of rectifying his soul for the sake of Hashem, and even if he were close to the angels in their good qualities, their praiseworthy ways, their efforts in Avodat Hashem, and their pure love of Him, cannot be compared with the merit of one who directs people onto the correct path and brings back the wicked ones to the service of Hashem. This one’s merits are multiplied on account of the merits of those whom he influenced, every day and at all times.
Rabbi Dessler writes (Michtav Me’Eliyahu III, pg. 93): Hashem told Bnei Yisrael, “My children, open for Me an aperture in teshuvah the size of a needle’s hole, and I will open for you openings which wagons and carriages can enter.” This refers to a mitzvah which a person does for himself. But what merit does he attain by influencing his fellow man? One multiplies his merits in proportion to the amount of merit he brought to the public. The siyata di’Shemaya that they achieve for all of the small apertures that they opened by doing teshuvah, for generations to come, is all considered his merit. In the World to Come, he will receive untold reward for all of their achievements.