When judges give preference to the letter of the law and ignore the spirit of the law, they, knowingly or unknowingly, violate the law's main purpose, which is to serve justice.
When we want changes in a hurry, we don't think much about the methods, hence the changes don't last. When we want to dispense justice in a big way but don't pay attention to legal details or the due process, then fairness, a precondition of justice, is not assured. When we want to punish culprits en masse but don't allow much scope for the accused's rights, it smacks of vengeance. This creates doubt about the credibility of the legal process and its outcome in the public mind.