Why were the government officials afraid of the government inspector?
The officials are primarily anxious about the fact that that the Inspector will carefully scrutinize their governance and that he may discover irregularities such as their poor performance and corruption. They are also worried that the Inspector's investigation will expose some dissatisfaction and that, consequently, they may be accused of treason. Furthermore, they are concerned about the fact that the Inspector will be traveling incognito and they will therefore not know who he is. The Inspector may, as a result, be inspecting them without their being aware of his presence. They may be caught doing wrong or neglecting their tasks. The mayor calls a meeting to discuss the impending visit and points out each official's faults.
Zemlyanika, the hospital manager, is, for example, concerned about the poor state of his hospital and the soiled and bedraggled attire his patients wear. He has also been allowing patients to smoke strong tobacco and has not provided adequate notification of patients' illnesses above their beds. Lyapkin-Tyapkin, the judge, loves hunting and keeps leisure equipment in his courtroom. Furthermore, he has allowed the porter to rear geese in the vestibule. One of his employees is clearly an alcoholic, and the judge is asked to instruct him to eat garlic to disguise the smell of liquor.
Hlopov, the head of the school, seems to have some problematic educators in his care and is told to cover up many of their shortcomings lest they offend the Inspector during his visit. The mayor is just as incompetent and corrupt as his colleagues and takes bribes and has women flogged. The postmaster illegally opens up private mail to pry into the affairs of others.
The officials agree to clean up their departments and cease their corrupt practices. It is ironic that when the person assumed to be the inspector finally makes his entrance, he is presented as corrupt himself. He makes debts that he cannot repay and is a gambler and a flirt. He abuses the power he has and borrows money from whoever he encounters. The officials keenly provide him with what he asks, believing that they can gain some influence or advantage and that the Inspector will hold them in good regard.
In a final twist, the officials learn that they have been duped. The person who they believed was the Inspector is a minor government official who exploited their gullibility and guilt. The mayor and his cronies later learn, to their utter shock and dismay, that the real Inspector-General has arrived and that he wants to meet them in the inn immediately.
Government officials, particularly in this story, are always looking for two things, one is more power, and the other is how to get away from folks more powerful than them, or at least to curry their favor. So in this case, the officials knew that the inspector had the power to fire them or appoint others in their stead or to simply close the door on their scheming and their rather comfortable existence in their little town.
There is also a reputation that the inspector has for being incredibly demanding and also having the ear of the big man in charge so they have to make sure that everything is kosher for him.