When rich children go to Beijing to take exams, they will bring some servants, talented people and some domestic servants. Although the number is small, rabbits will bite when they are impatient, and bandits are generally not too fierce, but some bandits nearby gather together. So for these armed forces, they will not easily start work. Unless they are too ostentatious and say how rich their family is, the bandits will start work. As for poor scholars, it is a problem to eat by themselves. They live every day just to take exams in Beijing. For bandits, there is no need for them to rob. Mosquitoes are meat no matter how small they are, but they are not delivered by themselves. These boors can't stand this.
Another reason is that people who can take the Beijing exam must pass the provincial exam, and only after passing the provincial exam can they be called Jinshi. Scholars still had some prestige in ancient times. And passing the provincial exam shows that this person has some strength. If one day he is admitted, it will be a dead end for himself. As a bandit, I made too many enemies. If we add another government army, it will be extremely unfavorable to the bandits. Moreover, bandits are generally rural farmers, and it is difficult to distinguish the depth of bookishness. Bandits can't guess the strength of scholars, so naturally they dare not lay hands on them easily. Over time, the bandits stopped attacking the scholar.
Finally, I think the ancients didn't value scholars. Isn't there a saying that all useless people are scholars? I think bandits look down on them, too. Some bandits are chivalrous and won't bully these weak people.