Part of a lawyer's role in defending a criminal case involving a guilty defendant is to perform
the larger civic role of constantly monitoring the law enforcement system for police misconduct that incidentally benefits the client (and that is one reason why a court doesn't want to let a lawyer withdraw when the defendant is likely to be guilty but there are indications of police misconduct in the case).