What the Sanhedrin says, goes. The people do not have the right to disregard their rulings or the laws they institute. Rather, we must follow them without deviating “left or right.” This means that even if we think they're wrong - that they “don't know their left from their right” in a certain matter - we must still comply with their decision.
The reason for this mitzvah is that God knows human nature better than we know ourselves. There has to be some governing authority when it comes to understanding the Torah. As we said, if we left it to each person to interpret the law for himself, we'd end up with an infinite number of practices calling themselves “Judaism.” Therefore, God established that the Sanhedrin would have the final say when it came to interpreting the Torah and deciding the law.
Is the way the Sanhedrin ruled necessarily the only way things could have been? Not at all! The Talmud is full of varying opinions. But when a matter is decided, it's settled. The Torah tells us “lo baShamayim hi,” the Torah is not in Heaven (Deuteronomy 30:12). It was given to mankind to rule on matters of law and, once decided, those laws are the final word. There's a famous story involving Rabbi Eliezar in Talmud Baba Metzia (59b). He was so convinced that his individual opinion was correct that he invoked all sorts of miracles to support his case. His colleagues informed him that the law is not decided based on Heavenly signs, no matter how impressive. The Torah was given to man and laws are decided based on majority consensus of the Sanhedrin. Similarly, even though Rabbi Yehoshua disagreed with the majority about the day on which Yom Kippur fell one year, he was obliged to comply with the consensus and not with his own calculations (Talmud Rosh Hashana 25a).
While Rambam (Maimonides) applies this mitzvah both to laws the Sanhedrin makes interpreting the Torah and those they instituted as protective measures, the Ramban (Nachmanides) disagrees. He says this mitzvah only applies when the Sanhedrin interprets and rules in matters of Biblical law but not in the case of rabbinic laws that they themselves enacted.
This mitzvah applies in all times and places. It is discussed in the Talmud in tractate Sanhedrin (86b-89a), as well as in Brachos (19b), Shabbos (23a), Succah (46a) and elsewhere. This mitzvah is codified in the Mishneh Torah in the first chapter of Hilchos Mamrim. It is #312 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos and #158 of the 194 negative mitzvos that can be observed today as listed in the Chofetz Chaim’s Sefer HaMitzvos HaKatzar.