Our Sages taught that batei midrash raise a person from being judged negatively to being judged favorably. When a person enters the beis midrash he examines his deeds, and as a result changes his way and is thereby judged favorably.
An alternate explanation is that a person is judged on Rosh Hashana according to the majority of his deeds, and if his evil deeds outweigh his good deeds, he might tip the scales to his favor by entering a beis midrash and learning Torah for a few hours. Since every minute he performs hundreds of mitzvas, within a few hours he can easily outweigh all the evil deeds he did all year long. And sometimes he has more merits than misdeeds, but since he sat idle for hours, he needs to compensate for that misdeed by investing extra effort in his learning. Thus it states, ‘life and death depend on the tongue’ for the tongue can add an immense number of merits within a short span of time, but it can also do the converse. So, a person should be extremely careful with his tongue, as is said in the name of Rav Hai Gaon, it should be harder for a person to move his tongue in speech than to lift a heavy beam.