Basically, everyone has the right to a just and proper defence, and it is the duty of the barrister to ensure this happens. People can be convicted based on questionable evidence, as explored in this article about Michael Wolkind QC: telegraph.co.uk/news/science/9115916/The-case-against-DNA.html
If it seems perfectly clear that there is no way for a client to walk away scot free, a barrister tries to go about things in a different manner.