I think you're reading this particular passage out of context. The verses you cite are immediately followed by what is called the "fruits of the spirit". In context the passage says:
16 So I say, walk by the Spirit, and you will not gratify the desires of the flesh. 17 For the flesh desires what is contrary to the Spirit, and the Spirit what is contrary to the flesh. They are in conflict with each other, so that you are not to do whatever[c] you want. 18 But if you are led by the Spirit, you are not under the law.
19 The acts of the flesh are obvious: sexual immorality, impurity and debauchery; 20 idolatry and witchcraft; hatred, discord, jealousy, fits of rage, selfish ambition, dissensions, factions 21 and envy; drunkenness, orgies, and the like. I warn you, as I did before, that those who live like this will not inherit the kingdom of God.
22 But the fruit of the Spirit is love, joy, peace, forbearance, kindness, goodness, faithfulness, 23 gentleness and self-control. Against such things there is no law. 24 Those who belong to Christ Jesus have crucified the flesh with its passions and desires. 25 Since we live by the Spirit, let us keep in step with the Spirit. 26 Let us not become conceited, provoking and envying each other.
The contrast is between the works of the flesh (i.e. your own power), which when directed towards the flesh, end up not where we want to be. By contrast, when our flesh IS KILLED, we must live in the spirit.
Earlier, Paul had said (2:19 -21)
19 “For through the law I died to the law so that I might live for God. 20 I have been crucified with Christ and I no longer live, but Christ lives in me. The life I now live in the body, I live by faith in the Son of God, who loved me and gave himself for me. 21 I do not set aside the grace of God, for if righteousness could be gained through the law, Christ died for nothing!”
The entire argument is that you cannot, in your own power, live a holy life. If one (and I say this as an ordained minister) tries to be good out of sheer willpower, you get the pedophiles and the other junk. It doesn't matter if one is trying to be good or not - the result of the power of the flesh will always be bad stuff.
The question isn't "does trying to be good make me do bad?" but rather "is man able to do any good whatsoever?" While by no means universally accepted, the doctrine of total depravity simply says no. Again, not all Christians say Total Depravity, but deviations from this position are degrees, and not disagreement. At the "other end of the spectrum" are those who say that man is sometimes capable of choosing to do good, but we'd all start by saying we sin!
It is only when our wills crucified with Christ - that we live in the Spirit - that we can attain the good life that is desirable.
The fruit of the Spirit is what we want - love, joy, peace, self-control - there aren't laws against the Spirit! We have to put laws on the natural self, because apart from Christ, we cannot do the good things we want.
In our own power, "even our righteousness is as filthy rags." In the Spirit, even our sins are redeemed.