The pasuk says in Yeshaiya (11:3), in reference to Moshiach - והריחו ביראת השם ולא למראה עיניו ישפוט ולא למשמע אזניו יוכיח - the judgement whether one has yir'as hashem will be done by smell, not sight or vision. The idea is explained by the Radak that the sense of smell is very sensitive - without much exposure and even from a distance one can detect an odor with their smell. Similarly, with a keen sense of smell the Moshiach will have the ability to distinguish between the tzadik an the rasha. In our gemara Rava explains that he will be מורח ודאין - smell and judge. From the mere scent of a person, Moshiach will have the ability to judge him. The gemara says that when bar koziva claimed to be the moshiach, he was tested to see if he has this keen sense to judge by smell and when the Rabbonon saw that he lacked this ability he was killed. Rashi in Yeshaiya attributes this keen sense to the wisdom of Hashem - כי בחכמת הקב"ה בקרבו ידע ויבין מי זכאי ומי חייב.
Rav Nota Greenblatt in his sefer "k'reich sadeh" on the haftorah of mikeitz, points out that rashi considers this ability to be a chochmah of Hashem. With this he explains the Rambam (Teshuva 9:2) - מפני שאותו המלך שיעמוד מזרע דוד בעל חכמה יהיה יותר משלמה. What is the source of the Rambam that the moshiach will possess wisdom greater than Shlomo HaMelech? It is from this pasuk that Moshiach will have a sense to be able to judge in ways that we don't see Shlomo was able to judge. Rambam and Ra'avad (Hilchos Melachim perek 11) argue whether the melech hamoshiach must perform a miracle to be trusted. Rambam proves that he doesn't from the fact that R. Akiva himself became a follower of ben koziva and didn't ask for a miracle. But, the Ra'avad holds that he must do a miracle as we see from our gemara that they tested him whether he can judge by scent. Perhaps they argue whether this level of perception is considered a miracle to confirm himself as moshiach, or just an extreme level of wisdom but not miraculous. R. Nota concludes by writing that in every generation we are blessed with gedolim who have this keen sense on some level of "judging by scent" to distinguish between emes and sheker. Sometimes there are issues that come up which the chachamim deem dangerous, but are unable to articulate the exact danger - they are being מורח ודאין - judging with their keen sense of smell.