"You shall not curse God [the judge]" (Exodus 22:27). One might think that if he merely said to him "you are cursed" he is liable. Scripture says "you shall not curse God," telling us he is not liable until he specifies the Divine Name or a substitute title. Rabbi Eliezer ben Yaakov says: "You shall not curse God" comes to give the warning against blaspheming the Name. One might think that if he cursed them after their death he is liable. And this would follow by reasoning: if for the lesser offense [of injury] one is liable after death, then for the greater offense [of cursing] is it not logical that one should be liable after death? Scripture says, "You shall not curse the deaf" (Leviticus 19:14). Just as the deaf person is distinct in that he is alive, so all the law concerns one who is alive; and one who curses the dead is exempt. "You shall not curse God." This teaches that one who curses the judge transgresses on two counts: on account of the judge and on account of his fellow. "And you shall not curse a leader among your people" (Exodus 22:27). This teaches that one who curses the leader transgresses on three counts: on account of the judge, on account of his fellow, and on account of the leader. "A leader among your people you shall not curse": one who follows the custom of your people, excluding one who has departed from the ways of the community, like Jeroboam son of Nebat.
The Ban on Cursing the Judge and the Leader of Israel
Mekhilta DeRabbi Shimon Ben Yochai 22:27
אלהים לא תקלל יכול אם אמר לו ארור אתה יהא חייב ת"ל אלהים לא תקלל מגיד שאינו חייב עד שיפרש בשם או בכנוי: ר' אליעזר בן יעקב אומר אלהים לא תקלל ליתן אזהרה על ברכת השם: יכול אם קללן לאחר מיתה יהא חייב ודין הוא ומה עונש מועט חייבין עליו לאחר מיתה אזהרה מרובה אינו דין שיהוא חייבין עליו לאחר מיתה ת"ל (ויקרא י"ט י"ד) לא תקלל חרש מה חרש מיוחד שהוא חיים אף כל שהוא בחיים והמקלל את המת פטור: אלהים לא תקלל. מלמד שהמקלל את הדין עובר משום שתים משום דין ומשום חבירו: ונשיא בעמך לא תאור. מלמד שהמקלל את הנשיא עובר משום שלש משום דיין ומשום חבירו ומשום נשיא: נשיא בעמך לא תאור. בנוהג מנהג עמך פרט לשפירשו מדרכי צבור כירבעם בן נבט: