John Gill's Exposition of the Whole Bible
Psalms 119:67
Before I was afflicted, I went astray,.... From God; from his word, his ways and worship; like a lost sheep from the shepherd, the fold, the flock, and the footsteps of it; see Psalms 119:176; Not that he wilfully, wickedly, maliciously, and through contempt, departed from his God; this he denies, Psalms 18:21; but through the weakness of the flesh, the prevalence of corruption, and force of temptation, and very much through a careless, heedless, and negligent frame of spirit, he got out of the right way, and wandered from it before he was well aware. The word is used of erring through ignorance, Leviticus 5:18; this was in a time of prosperity, when, though he might not, like Jeshurun, wax fat and kick, and forsake and lightly esteem the Rock of his salvation; or fall into temptations and harmful lusts, and err from the faith, and be pierced with many sorrows, as too much love of the world brings men into; yet he might become inattentive to the duties of religion, and be negligent of them, which is a common case;
but now have I kept thy word: having been afflicted with outward and inward afflictions, afflictions of body and mind; afflictions in person, in family and estate; afflictions in soul, through indwelling sin, the temptations of Satan, and the hidings of God's face: all this brought him back again to God, to his word, ways, and worship; he betook himself to reading and hearing the word, if he might find any thing to relieve and comfort him under his trials; he observed the doctrines of grace in it, and kept the precepts of it, and walked in all the commandments and ordinances of it, being restored by afflictions.