Throughout the Bible, we can see examples of just and righteous men; these men are deemed thus by both action and inaction- by what they do and do not do. In Ezekiel 18:5-9, God defines a just man:
restored his pledge to debtor__ _________
given his bread to the hungry__________
covered the naked with clothing___
withdrawn his hand from iniquity__________
executed true judgement between men be_ _________
walked in God's statutes______
kept God's judgements faithfully_ _
not eaten on the mountains
not lifted his eyes to idols
not defiled his neighbor's wife_
not approached woman during her impurity
not oppressed anyone
robbed no one by violence
not exacted usury (loan interest)
not taken any increase
Similarly, in the first verse of Psalm 15, David asks God, "Jehovah, who may abide in Your tabernacle? Who may dwell in Your holy hill?" Verses 2-5 answer:
And works righteousness,
And speaks the truth in his heart;
He who does not backbite with his tongue,
Nor does evil to his neighbor,
Nor does he take up a reproach against his friend;
In whose eyes a vile person is despised,
But he honors those who fear the LORD;
He who swears to his own hurt and does not change;
He who does not put out his money at usury,
Nor does he take a bribe against the innocent.
He who does these things shall never be moved."
Examine the parable of an unclean spirit's return in Luke 11:24-26. A demon leaves a person for a time but then decides to return. When he arrives, he finds his "home" in put in order, so he gathers seven other more wicked spirits to dwell with him in his host. Thus the last state of the man is worse that the first.
We can find ourselves in a similar situation if we just clean out our lives by eliminating unholy things in them. 2 Peter 2:20-21 tells us that "if, after [we] have escaped the pollutions of the world through the knowledge of the Lord...[we] are again entangled in them and overcome, the latter end is worse for [us] than the beginning." These are the "3rd soil" in the parable of the sower: "Now the ones that fell among the thorns are those who, when they have heard, go out and are choked with cares, riches, and pleasures of life, and bring no fruit to maturity." (Luke 8:14)
When we remove sinful things from our lives, we must replace them with righteous things- we must fill the void, "putting off...the old man...and putt[ing] on the new man" (Eph 4:17-24)- or we strongly risk falling back into the world. Consider Luke 11:33-36. This passage tells us that we should fill ourselves with light such that there is no part darkness. By filling ourselves with the Word of God and taking the actions described in the New Testament- visiting orphans and widows (Jas 1:27), loving the Lord will all our heart, soul, mind, and strength (Mark 12:30), loving our neighbor as ourselves (Mark 12:31), doing good to those who hate us (Luke 6:27), submiting to our husbands/loving our wives (Eph 5:22-33), etc. - we can become the righteous person described in Ezekiel and Psalm 15, and our lives will glorify the Lord. The key to being pleasing to God is striving to do the things He likes and to refrain from the things He does not.
One final note on the subject: just because the commands of God instruct us in works we should and should not be doing does not mean that we are in any way earning anything. "For by grace you have been saved through faith, and that not of yourselves; it is the gift of God, not of works, lest anyone should boast. For we are His workmanship created in Christ Jesus for good works, which God prepared beforehand that we should walk in them." (Eph 2:8-10)