A prophet from among you…God will establish –him you shall heed. (Deuteronomy 18:15)
As opposed to all of the various wizards, warlocks, sorcerers and conjurors, whom we are warned to shun, we are told that we are to heed the words of legitimate prophets, who represent the word of God. The prophets were even empowered to temporarily suspend most mitzvos in a time of great need (though they could not retract or edit anything written in the Torah).
The reason for this mitzvah is that prophecy is the highest level a person can hope to achieve. (Back in Bible times, there were schools where people trained in the hopes of reaching this exalted state.) Once a person has been recognized as a legitimate prophet, it’s a sure sign of his personal greatness, as well as being “in tune” with the will of God. Such people are of the highest caliber and, once confirmed as legitimate prophets, it is surely wise to heed their words. (Prophets typically delivered such messages as “be good to one another” and “repent,” which would be good advice even coming from non-prophets.)
This mitzvah applies to men and women at a time when there are prophets among us. It is discussed in the Talmud in tractate Sanhedrin on pages 89a-b. It is codified in the Mishneh Torah in Hilchos Yesodei HaTorah chapters 7 and 9. This mitzvah is #172 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos.