Here is how you save yourself through the works of the law...you must be perfect in your life (keeping the law impeccably) from the moment of your conception into all of eternity (Galatians 3:10-13, James 2:10, Matthew 5:48)...
(As a three-year-old, I thought that I had my t's crossed and my i's dotted as my mother listed the commandments. But commandment #10 got me. Every one of us has wanted something that didn't belong to us, before we got saved.)
...You can try to do it that way...or you can realize that Jesus lived a perfect life and then died in your place, taking the penalty for your sin. Thus His righteousness is applied to your account; because your sin was applied to His account as He took the righteous wrath of God upon Himself, that belonged to you...He didn't deserve to be punished...you did. You didn't deserve to go to heaven...He did. But He was punished so that you can go to heaven. Theologically it is called substitution or the divine exchange.
Also, if anyone is going to insist that they are going to be saved through their works, Jesus is clear on the matter in John 6:28-29, in saying that the only work that will save you is a simple faith in the One whom God hath sent...and that is all that is required.
Now faith produces results in the life of anyone who truly believes...see 2 Corinthians 5:17.
True believers have the love of the Lord in their hearts...Romans 5:5, Luke 7:36-50, 1 John 4:19...and this love is the fulfilling of the law...Romans 13:8-10, Galatians 5:14...and it is a practical love...1 John 3:17-18.
However we do not obtain this love by doing some good deed like giving $5 to the poor...or even $1,000,000 wouldn't cut it. This transformation is effected through faith in what Jesus did for you on the Cross, not by any work of righteousness which you have done or will do (Titus 3:4-7).
For He said from the Cross, "Father, into thy hands I commend my spirit." and the same Spirit was poured out on the early church on the day of Pentecost and has been in every believer ever since. God provided His Spirit and His blood in order to deal with the sin in our lives...see Matthew 1:21 and Titus 2:14...however this righteousness is first imputed to us apart from works...see Romans 4:6.
We are declared righteous through faith in Christ' shed blood (Romans 5:9, Romans 5:1, Romans 3:25)...and this righteousness is our identity in Christ even when we blow it...Romans 4:5. So then, knowing that your identity is that you are righteous in Christ and that this cannot be changed or compromised by sin...the exhortation is that you begin to live like you are who the Lord says you are...that you begin to live like you are righteous in Him...for you are the righteousness of God in Him...2 Corinthians 5:21.
And also, it is impossible for God to lie; and therefore, when God declares you to be righteous, it means that you are righteous...see 1 John 3:7.