I tell you... The Lord rebuked them for the gravity of their sin and their malice; here he warns them about the future judgment, which we hold by faith: "Be afraid of the sword, for anger brings the punishment of the sword; for know that there will be a judgment" (Jb 19:29); "He will make room for every act of mercy; everyone will receive in accordance with his deeds" (Sir 16:14). Again 2 Corinthians (5:10): "For we must all appear before the judgment seat of Christ, so that each one may receive good or evil, according to what he has done in the body." Hence there will be an investigation, bec...ause each one will render an account of his deeds. Therefore, he also adds something about words: I say to you, on the day of judgment men will render account for every careless word they utter. This is said in Wisdom (1:9): "He that speaks unrighteous things will not escape notice" and that the sound of murmuring will not go unheard. Why does he say for every careless word? A word is called idle in two ways: in one way every evil word is called idle; because that is called idle which does not attain its purpose, as when a person hunts for a man and does not find him, the search is said to have been idle. But if a word is given to instruct, when it succeeds, it is not idle: "Let no evil talk come out of your mouths, but only such as is good for edifying, that it may impart grace to those who hear" (Eph 4:29). And according to Chrysostom, it refers to the fact that they said, "by Beelzebub". That word was most pernicious and also idle. According to Jerome the former is a word that inflicts harm, and an idle one is that which does not afford any benefit. According to Gregory any word lightly spoken is called idle, unless it has a pious use or a pious need. But it is clear that they spoke a pernicious word. Why does he mention only idle? Because he wishes to argue from the lesser; because if one must render an account for an idle word, then more so for a pernicious one.
Source: Commentary on Matthew