Did you ever hear someone say that something is “only a rabbinic law?” Well, in this mitzvah we see that the Torah commands us to follow rabbinic laws, so there's nothing “only” about it! In this matter it makes no difference whether the rule is one in which the Sages interpreted the Torah or one they invented themselves (because rabbinic laws can be of both kinds). The Midrash understands “the law they will teach you” to refer to the safeguards instituted by the rabbis and “the judgment” to refer to the rules they derived through Biblical interpretation. The final clause of our verse, “that which they tell you,” to refer to the Oral Law. (See Mishneh Torah, Hilchos Mamrim 1:2.)
A court may not overturn the ruling of an earlier court unless they are greater both in terms of number and in terms of wisdom. When it comes to something enacted in order to keep the people a safe distance from the possibility of sin, then a later court may never rescind an earlier court’s ruling.
Every generation must afford its judges the same authority regardless of how they compare to the Sages of other times. Samuel was a prophet and one of the greatest judges. (Perhaps the greatest, being compared favorably to Moses and Aaron by King David in Psalms 99:6.) Yiftach (Jephthah) was one of the most flawed. Nevertheless, the Talmud in Rosh Hashana (25b) understands Deuteronomy 17:9 (“to the judges that will be in those days”) to require us to treat our leaders like Samuel, even if they’re more like Jephthah. (Nowadays, we might be lucky to get a Jephthah!)
The basis underlying this mitzvah is what we said in Mitzvah #78: there has to be a unified religious standard. If we left every person to interpret the law for himself, there would be as many versions of Judaism as there are Jews! In order to have a functioning society, we must follow the Torah as our authorities explain it to us.
When there was a Sanhedrin, which served as Judaism's Supreme Court, their word was the final matter. Now, in the absence of such a governing body, there are a multitude of opinions leading to different minhagim among Sephardim, Ashkenazim, Yemenites, Chasidim, etc. Each person should consistent follow the rulings of his authority as both these and those represent the words of the Living God (Talmud Eiruvin 13). What's important is to choose an authority and to follow him consistently. The Talmud tells us that to always follow the lenient opinion is wicked, while to always follow the stringent opinion is foolish (Chulin 44a). An honest evaluation of a matter will lead to some leniencies and some stringencies. A person must follow his halachic authority in both.
This mitzvah applies specifically when there’s a Sanhedrin. In the Talmud, it is discussed in the tractate Sanhedrin (86b-89a). It is codified in the Mishneh Torah in the first chapter of Hilchos Mamrim and is #174 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos.