1 Samuel 12:14
If ye will fear the LORD, and serve him, and obey his voice, and not rebel against the commandment of the LORD, then shall both ye and also the king that reigneth over you continue following the LORD your God: If ye will fear the LORD, and serve him, and obey his voice, and not rebel against the commandment of the LORD, then shall both ye and also the king that reigneth over you continue following the LORD your God:
The condition was laid down after Israel had sinned by rejecting God's direct rule and insisting on a king like the surrounding nations, yet God did not abandon His people. Both the people and the king set over them were told they could still continue following the Lord their God. That continuance depended on fearing the Lord, serving Him, obeying His voice, and not rebelling against His commandment. The promise was conditional, leaving the way open for them to turn back to God through humility and repentance despite their wrong course.
For the king in particular, remaining secure on his throne depended on trusting God and obeying His will. So long as those conditions were met, divine guidance and protection were assured to him. Saul's course stands as the warning of what follows when those conditions are refused. By rebellion and persistent resistance to the Spirit he turned away from God and forfeited the security obedience would have brought.