If we confess our sins, he is faithful and righteous to forgive us the sins, and to cleanse us from all unrighteousness.
The second reason why he wrote this epistle is in chapter 2, verse 1 John 1:1 . "These things write we unto you, that ye sin not." And so, the purpose of this epistle is to bring to you a life of victory over sin, to give you power over sin.