Why do defence lawyers have an obligation to defend their clients to the best of their ability regardless of the crime they are accused of?

Why do defence lawyers have an obligation to defend their clients to the best of their ability regardless of the crime they are accused of?