The word “elohim” is a strange one. Meaning “powerful ones,” It can refer to God, though in that case we would capitalize it and pronounce it “Elokim” in conversation. (It would also take a singular verb form as in “Breishis bara Elokim,” the verb “bara” meaning “He created.”) It can also refer to judges as in Exodus 22:8, “the one whom the judges (elohim) shall find guilty.” The use of this word in this verse gives it a double meaning, as we shall see in this mitzvah and the next.
The reason for this prohibition is to enable the judges to do their jobs. It would be very unnerving for them to try and administer justice if they were intimidated and incapacitated by the fear that those found guilty would constantly be heaping curses upon them. This mitzvah also tells the people not to despise the judges. They have a duty to perform that is often unpleasant, but it is a duty that needs performing nonetheless. In short, this law discourages rebelling against the legal system, leading to anarchy.
There is a separate prohibition against cursing any other Jew, as we will see IY”H in Mitzvah #231. If someone curses a judge, he violates both prohibitions simultaneously.
This mitzvah applies to both men and women, in all times and places. It is discussed in the Talmudic tractate of Shevuos on page 36. In the Shulchan Aruch, it is found in Choshen Mishpat 27. It is #315 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos and #63 of the 194 negative mitzvos that can be fulfilled today as listed in the Chofetz Chaim’s Sefer HaMitzvos HaKatzar.