**Disclaimer** This is not actual legal advice, this is only for entertinament purposes only
The law school answer is that your role is to ensure your client gets a fair trial and your knowledge of the defs guilt or not is irrelevant.
Even if you tell your attorney that you are guilty as charged, he/she is still able to defend you.
It is the burden of the state to prove that you are guilty of crimes beyond a reasonable doubt.
If the state does not meet its burden, then you should be found not guilty, even if you in fact committed the crimes in question.
Therefore, even if your lawyer knows with 100% certainty that you are guilty, that does nothing to change the fact that the state is responsible for proving your guilt, and your lawyer is still responsible for making the state work to prove its case.
What if evidence was illegally seized?
What if the state’s theory of the case makes no sense?
What if the witnesses against you are all known liars?
All of this could affect the state’s ability to make its case, and it is your lawyer’s responsibility to point all of this out.
That being said, lawyers are still officers of the court, and therefore, we have ethical responsibilities to the justice system independent of our duties to our clients.
One of the intersections between duty to a client and duty to the justice system comes with perjury, i.e., knowing falsity.
As a lawyer, I can attack my opponent and his/her evidence, and I can offer up arguments that may be less than rock solid, so long as they are reasonably supported by the evidence.
But I cannot lie, and I cannot offer your testimony if I know it is false.
So if you tell your lawyer you are guilty, that limits what he or she can put in filings or present in court: a lawyer can still say that the state hasn’t met its burden and its case makes no sense, for example, but he or she could not say "my client is innocent," or allow you to testify to your innocence, and sometimes, that’s what a jury needs to hear.
You should never lie to your attorney, as generally speaking, this is going to backfire.
Further, the attorney-client relationship is confidential because in order to provide the best possible defense, a lawyer needs to know all the evidence in a case, even the bad evidence.
A lawyer can do much more to deal with bad facts if he/she learns them early on in the case.
But, bottom line, if you are guilty, you are likely harming your case by sharing this fact with your lawyer, unless your goal is to enter an immediate guilty plea or have your lawyer negotiate a plea bargain.