John Flavel, from On Keeping the Heart:
To keep the heart, necessarily supposes a previous work of regeneration, which has set the heart right, by giving it a new spiritual inclination, for as long as the heart it not set right by grace as to in habitual frame, no means can keep it right with God. Self is the poise of the unrenewed heart, which biases and moves it in all its designs and actions; and as long as it is so, it is impossible that any external means should keep it with God.
Man, originally, was of one constant, uniform frame of spirit, held one straight and even course; not one thought or faculty was disordered: his mind had a perfect knowledge of the requirements of God, his will a perfect compliance therewith; all his appetites and powers stood in a most obedient subordination.
Man, by the apostasy, is become a most disordered and rebellious creature, opposing his Maker, as the First Cause, by self-dependence; as the Chief Good, by self-love; as the Highest Lord, by self-will; and as the Last End, by self-seeking. Thus he is quite disordered, and all his actions are irregular. But by regeneration the disordered soul is set right; this great change being, as the Scripture expresses it, the renovation of the soul after the image of God, in which self-dependence is removed by faith; self-love, by the love of God; self-will, by subjection and obedience to the will of God; and self-seeking by self-denial. The darkened understanding is illuminated, the refractory will sweetly subdued, the rebellious appetite gradually conquered. Thus the soul which sin had universally depraved, is by grace restored. This being pre-supposed, it will not be difficult to apprehend what it is to keep the heart, which is nothing but the constant care and diligence of such a renewed man to preserve his soul in that holy frame to which grace has raised it. For though grace has, in a great measure, rectified the soul, and given it an habitual heavenly temper; yet sin often actually discomposes it again; so that even a gracious heart is like a musical instrument, which though it be exactly tuned, a small matter brings it out of tune again; yea, hang it aside but a little, and it will need setting again before another lesson can be played upon it. If gracious hearts are in a desirable frame in one duty, yet how dull, dead, and disordered when they come to another! Therefore every duty needs a particular preparation of the heart. ” If thou prepare thine heart and stretch out thine hands toward him,” To keep the heart then, is carefully to preserve it from sin, which disorders it; and maintain that spiritual frame which fits it for a life of communion with God.