Thus you will walk in the ways of good men and keep to the paths of the righteous. For the upright will live in the land, and the blameless will remain in it.
I. Walk The Ways Of Good Men
It cannot be the other way around, once you stay long enough with bad people or the unconverted or the unbelievers, you will be corrupted in your good manners, the only reason to stay with them is to share to them the Lord Jesus Christ and nothing else. You can never be good friends with them, only acquaintances.
Pro 13:20 Keep company with the wise and you will become wise. If you make friends with stupid people, you will be ruined.
1 Corinthians 15:33 Be not deceived: evil communications corrupt good manners. (KJV)
1 Corinthians 15:33 Do not be fooled. "Bad companions ruin good character." (GNB)
Psa 119:63 I am a friend of all who serve you, of all who obey your laws. (GNB)
Psa 119:115 Go away from me, you sinful people. I will obey the commands of my God.
Hebrews 6:12 We do not want you to become lazy, but to be like those who believe and are patient, and so receive what God has promised.
II. Keep In The Paths Of The Righteous
Always do what is right, and what is according to God's Words. Don't stop reading and meditating God's Words, the Holy Bible on a daily basis so you can "walk" according to it. Majority are always wrong, those who only follow God's Words are only a few good men, stick to the Bible. Turn down an opinion but follow and obey God's Words to the fullest.
3Jn 1:11 My dear friend, do not imitate what is bad, but imitate what is good. Whoever does good belongs to God; whoever does what is bad has not seen God.
Exo 23:2 Do not follow the majority when they do wrong or when they give testimony that perverts justice.
Psa 37:27 Turn away from evil and do good, and your descendants will always live in the land;
John 12:26 Whoever wants to serve me must follow me, so that my servant will be with me where I am. And my Father will honor anyone who serves me.
III. Remain Upright In The Land
You need to focus on the Lord as the One who deserves to be worshipped, you can set up idols in your hearts thus these idols will destroy the very land from where you're standing. Keep it right. Worship the Lord and Him Alone.
Numbers 33:52 drive out all the inhabitants of the land before you. Destroy all their carved images and their cast idols, and demolish all their high places. (NIV)
Ezekiel 30:13 This is what the Sovereign LORD says: "'I will destroy the idols and put an end to the images in Memphis. No longer will there be a prince in Egypt, and I will spread fear throughout the land.
IV. Be Blameless
We need to be blameless, don't use grace as license to sin, but instead all the more "work" to keep our salvation perfect and secure. Work out your imperfections, until the coming of the Lord Jesus Christ.
Philippians 2:15 That ye may be blameless and harmless, the sons of God, without rebuke, in the midst of a crooked and perverse nation, among whom ye shine as lights in the world;
1 Thessalonians 5:23 And the very God of peace sanctify you wholly; and I pray God your whole spirit and soul