Our Sages teach us in Pirkei Avot (Chapter 5, Mishnah 18): “Anyone who brings merit to the public, no sin shall come through his hand.” The Tosafot (Yevamot 109b) question this, for Elisha ben Avuya taught Torah to Rabbi Meir and nevertheless, he strayed from the path, became a heretic, and was eventually called “the other one”. If so, how can we say that one who brings merit to the public shall have no sin come through his hand?
The Tosafot explain that if the individual who brings merit to the public is wicked from the onset, even before he brought about the merit to the public, it is possible that sin shall come through his hand. Thus, with regards to Elisha, who sinned by virtue of the fact that from his youth he would regularly sing Greek songs and carry with him heretical books that would fall out from beneath his cloaks, although he was great in Torah and brought merit to the public, nevertheless, sins came through his hand.
Nevertheless, the Iyun Yaakov explains this matter somewhat differently: When our Sages said that no sin shall come through his hand, this refers to sins performed inadvertently which bringing merit to the public protects one from. However, if one plans on transgressing a sin and does so purposely, such an individual shall not merit this Heavenly protection since every individual has the choice whether to sin or to be a faithful servant of Hashem.
The Sefer Anaf Yosef (quoted by Maran zt”l in his Anaf Etz Avot, page 370) writes that when our Sages taught that no sin shall come through his hand, this only refers to one who brings merit to the public by teaching others, thus causing others to observe and fulfill the Mitzvot as well as the individual fulfilling the Mitzvot himself. However, if one teaches others but does not fulfill the Mitzvot himself, our Sages said nothing about such a person and he shall bear many sins although he delves in Torah all of his days.
Indeed, Maran Ha’Chida writes in his Sefer Devarim Achadim (Darush 22) that one may certainly not study Torah and as a result, abstain from Keri’at Shema and prayer, for one shall be punished for such behavior. He proceeds to recount a terrible incident regarding one of the students of the Ramban who would study Torah extremely diligently on his table while abstaining from the Mitzvot of Keri’at Shema and prayer as a result. The Ramban brought this issue to his student’s attention several times but he did not heed his rabbi’s words. Once, when this student was not home, a non-Jewish horseman passed by and saw the daughter of this student and he proceeded to enter the house and abuse this girl upon the very table where her father would constantly study Torah. When the student saw this, he became extremely saddened. The Ramban told him, “Had I not warned you that there is a time for Torah study and a time for prayer? If you would have prayed with concentration and requested that Hashem protect us from bad people, you would have been saved from this tragedy. However, you did not heed my instructions.” Let us all learn the powerful lesson this story provides.