The ethical Torah writings such as the Book of Proverbs vehemently condemn flattering people to obtain their favor. When we do so, we may not care whether the object of our praise deserves it. Praising people who do not merit it has at least two harmful effects. First, it reinforces that person's behavior. Second, it delivers a dangerous message, particularly to young people who like to emulate recipients of honor.
We should instead rebuke wrongdoers, and if we cannot reprimand them, we can at least refrain from praising them.
The key is to avoid becoming dependent on those whom we do not respect. We should not seek any prestige they can offer, nor place our livelihood in their hands. Flattery may cause us to compromise ourselves, reinforce wrong behavior, and teach our children that we respect wrongdoing.
Furthermore, we gain nothing from our sycophancy. The Sages observed that those who flatter to obtain favors may end up disgraced (Avos De'R' Nosson 29:4).