"Then the word of the Lord came to Samuel, saying, 11“I regret that I have made Saul king, for he has turned back from following Me, and has not carried out My commands.” And Samuel was distressed and cried out to the Lord all night," (1 Sam. 15:10-11).
This is an example of anthropomorphic expression where God speaks in human terms and in human ways and often working through people--in time--and conditioning His comments contextually relative to the time and situation of the people. God expresses emotion over the sin of people, such as anger (Deut. 9:8), regret (1 Sam. 15:11), sorrow (1 Chron. 21:15 ), and pity (Judges 2:18). God is merely displaying proper emotions at the proper time even though He knew from eternity that people would sin. Analogy: I knew that my children would sin and grieve me before they were born but that does not mean I did not know or was surprised by their rebellion when it happened, nor does it mean that I can't express regret.
Furthermore, God is working relative to us, that is, He is working in our time frame and is expressing human-like emotions after seeing what people have done in their sinfulness. This is natural and is to be expected if we assume that God works with us and through us as we go about our daily lives.