God resists the proud and gives grace to the humble
The Bible says that God does not want anyone to perish (2 Pet. 3:9), that Jesus has given light to all men (John 1:9) and that we have no excuse for rejecting him (Rom. 1:20-21) since we are created for the precise purpose to seek him and find him (Acts 17:26-27). In this way God shows mercy to all, and Jesus also died for ALL (or else people would definitely perish, which God does not want).
Grace, favor, kindness, thanks, pleasure and benefit are some possible translations of the Greek feminine noun χάρις (charis, Strong’s 5485) used 157 times in the KJV, and we also have the Greek neuter noun χάρισμα (charisma, Strong’s 5486) meaning something like a divine favor, used 17 times in the KJV.
John 12:32 And I, if I be lifted up from the earth, will draw ALL MEN unto me.
Jesus Christ died for the whole world (John 3:15-17), so all are offered mercy/grace and must therefore not necessarily perish. We also know that not all people will choose to take the chance to be saved and rather prefer to live in darkness. The grace of God that brings salvation has been offered to ALL people, and the grace of God teaches us to stay away from sin here and now. We must not wait until death before we can stay faithful to God:
Titus 2:11 For the grace of God that bringeth salvation hath appeared to ALL MEN,12 Teaching us that, denying ungodliness and worldly lusts, we should live soberly, righteously, and godly, in this present world
Both in the Old and the New Testament the teaching is that we must forsake our old way of living and start living a holy live, in order to be given mercy.:
Isaiah 55:7 says “Let the wicked forsake his way, and the unrighteous man his thoughts and let him return unto the Lord, and He will have mercy upon him, and to our God, for He will abundantly pardon.”
So even if all people have been provided a way to God’s kingdom, God still chooses to resist the proud (those who refuse to believe, and/or those who refuse to follow him and serve him only). In this sense God gives grace only to the humble, because only the humble will benefit from the grace that God has offered to all:
Ja. 4:6 But he giveth more grace (χάρις). Wherefore he saith, God resisteth the proud, but giveth grace (χάρις) unto the humble.
1 Pet. 5:5 Likewise, ye younger, submit yourselves unto the elder. Yea, all of you be subject one to another, and be clothed with humility: for God resisteth the proud, and giveth grace to the humble.
Matt. 7:13 Enter ye in at the strait gate: for wide is the gate, and broad is the way, that leadeth to destruction, and many there be which go in thereat:14 Because strait is the gate, and narrow is the way, which leadeth unto life, and few there be that find it.
The Bible does not teach “once declared righteous, always righteous“. We will never be considered righteous unless we live righteous lives, and that goes for believers as well (see also Ez. 33). We are not “free” to disobey God either in the old or the new testament:
Ezekiel 18:4 Behold, all souls are mine; as the soul of the father, so also the soul of the son is mine: the soul that sinneth, it shall die.5 But if a man be just, and do that which is lawful and right,— 9 Hath walked in my statutes, and hath kept my judgments, to deal truly; he is just, he shall surely live, saith the Lord God.— 20 The soul that sinneth, it shall die. The son shall not bear the iniquity of the father, neither shall the father bear the iniquity of the son: the righteousness of the righteous shall be upon him, and the wickedness of the wicked shall be upon him.21 But if the wicked will turn from all his sins that he hath committed, and keep all my statutes, and do that which is lawful and right, he shall surely live, he shall not die.22 All his transgressions that he hath committed, they shall not be mentioned unto him: in his righteousness that he hath done he shall live.23 Have I any pleasure at all that the wicked should die? saith the Lord God: and not that he should return from his ways, and live?24 But when the righteous turneth away from his righteousness, and committeth iniquity, and doeth according to all the abominations that the wicked man doeth, shall he live? All his righteousness that he hath done shall not be mentioned: in his trespass that he hath trespassed, and in his sin that he hath sinned, in them shall he die.25 Yet ye say, The way of the Lord is not equal. Hear now, O house of Israel; Is not my way equal? are not your ways unequal?26 When a righteous man turneth away from his righteousness, and committeth iniquity, and dieth in them; for his iniquity that he hath done shall he die.27 Again, when the wicked man turneth away from his wickedness that he hath committed, and doeth that which is lawful and right, he shall save his soul alive.28 Because he considereth, and turneth away from all his transgressions that he hath committed, he shall surely live, he shall not die.29 Yet saith the house of Israel, The way of the Lord is not equal. O house of Israel, are not my ways equal? are not your ways unequal?30 Therefore I will judge you, O house of Israel, every one according to his ways, saith the Lord God. Repent, and turn yourselves from all your transgressions; so iniquity shall not be your ruin.31 Cast away from you all your transgressions, whereby ye have transgressed; and make you a new heart and a new spirit: for why will ye die, O house of Israel?32 For I have no pleasure in the death of him that dieth, saith the Lord God: wherefore turn yourselves, and live ye.
1 Pet. 4:17 For the time is come that judgment must begin at the house of God: and if it first begin at us, what shall the end be of them that obey not the gospel of God?18 And if the righteous scarcely be saved, where shall the ungodly and the sinner appear?
In Romans 9 (the Calvinists’ favorite) we can read about God’s mercy, which is a translation from the Greek verb ἐλεέω (eleeō, Strong’s 1653), and the term to have compassion which is a translation from the Greek verb οἰκτίρω (oiktirō, Strong’s 3627). Naturally God can choose to have mercy and compassion to whoever he wants, like those who have repented for their sins and who continue to follow him. You can read more about Rom. 9 in this article and this.
Rom. 9:15 For he saith to Moses, I will have mercy on whom I will have mercy, and I will have compassion on whom I will have compassion.—15 For he saith to Moses, I will have mercy on whom I will have mercy, and I will have compassion on whom I will have compassion.
We can also fall from grace, as you can read more about here. Examples:
Gal 1:6 I marvel that ye are so soon removed from him that called you into the grace of Christ unto another gospel
Gal. 5:4 Christ is become of no effect unto you, whosoever of you are justified by the law; ye are fallen from grace
Hebr. 12:15 Looking diligently lest any man fail of the grace of God; lest any root of bitterness springing up trouble you, and thereby many be defiled