You are right; the Bible does say that we can't be saved by being good or trying to keep God's laws - and the reason is because God's standard is perfection, and none of us is perfect. Jesus said that even our inner thoughts will condemn us: "I tell you that anyone who is angry with his brother will be subject to judgment" (Matthew 5:22).
This is why we need Christ, for only He can take away our sins and make us pure in the eyes of God. He was without sin - but He willingly allowed the stain of our sins to be transferred to Him, and He took the judgment we deserved. It's as if you were taken before a judge and pronounced guilty for something you had done - and then the judge stepped down and paid your fine out of his own pocket. The difference is that Christ paid for our salvation with the cost of His blood.
We don't keep the Ten Commandments in order to be saved; we keep them because we want to please God and bring honor to Him by the way we live. Jesus said, "If you love me, you will obey what I command" (John 14:15). The Bible also says, "Just as he who called you is holy, so be holy in all you do" (1 Peter 1:15).
Have you committed your life to Jesus Christ? If so, He now lives within you by His Holy Spirit, and His will is for you to turn your back on sin and - with His help - to live a life that honors God. Make this your goal - beginning today.