All the people said to Samuel, Pray for your servants to Yahweh your God, that we not die; for we have added to all our sins [this] evil, to ask us a king.
"The Lord will not cast away his people"  (1 Samuel 12:22).  The great factor underlying a promise like this was the purpose of God as revealed to Abraham that through his Seed (singular), the Messiah, God would bless all the families of the earth  (Genesis 12:3).  God's promise of the Messiah to be born of the posterity of Abraham absolutely required that God preserve and protect that posterity (Israel) until that goal was actually achieved in the birth of our Lord Jesus Christ.  Unfortunately the Israelites took advantage of that promise by their countless rebellions.