First I give definition of sin.
What is Sin?
Sin is an activity which renders the human soul sick and incapable of viewing the face of God. Difficulties have to be encountered in the journey which the soul undertakes as it moves towards the purpose of its creation.
Activities which amount to sinning are either physical whose dangers are visible to oneself as well as to others; or, they are spiritual. Of the physical activities many are such that the dangers and disabilities they entail are obvious.
What are good deeds? Good deeds are deeds which bring a person enough strength to join the onward march in the hereafter and which makes the soul capable of viewing the face of the Lord. Normally, a healthy person means one who is capable of going about life's activities in a normal way.
One does not have to be extra-capable. One has to be just capable. Otherwise, small defects exist in everyone. Doctors cannot point to a single perfectly healthy body. A good man is one who has done enough good deeds both physical and spiritual to be capable of viewing the face of God.
Way of the Seekers: What is Sin?
Now the question: how to be free from sin?
I would suggest to read pages 23-25 of the book How to be free from sin? by Mirza Ghulam Ahmad- the Promised Messiah and Imam Mahdi; the link is given below:
How to be Free from Sin