Generally speaking, a teacher must first ascertain the character of a student to determine if he is worthy of learning Torah before teaching him. The Rambam rules that if a student is found to be lacking in his religious and/or ethical behavior, the teacher would be obligated to first bring him to repentance. Only after he is found worthy will he be welcomed into the traditional house of study to learn Torah (see Mishneh Torah, Hilkhot Talmud Torah 4:1). This ruling notwithstanding, the Ba’al HaTanya writes in the Shulḥan Arukh HaRav that if it appears impossible to lead the student in the path of repentance, if he still desires to study Torah the teacher must “push him away with his left while drawing him near with his right,” in contrast with the behavior of Rabbi Yehoshua ben Peraḥyah who “pushed away” Yeshu HaNotzri with both hands (see Hilkhot Talmud Torah 4:17).
This idea comes up in the Gemara in the following context:
Rabbi Zeira said in the name of Rav: Anyone who teaches Torah to an unworthy student is like one who throws a stone to Markulis, for it is written: “As a small stone in a heap of stones, so is he that gives honor to a fool” (Mishle 26:8).
Markulis is the name given by the Sages for the Roman god Mercurius, who was also known as the Greek deity, Hermes. Among his many responsibilities, Mercurius was the patron of the highways and travelers. This position led many to erect statues of him on crossroads. Oftentimes, these representations presented just the head of the idol and passersby would place stones at the foot of the statue. On occasion the representation was simply a pile of rocks, and travelers who passed by the pile would toss their own stone on it as an offering to the god.