The people had been sacrificing to goat demons! (17:7) Can you believe that? Goat demons!?!? And after all that God had shown them and done for them! On the one hand, this is understandable; the people were great sinners and were always running away from God. On the other hand, it is almost unbelievable. Goat demons!?!? And that's not all! Injustices to neighbors, sexual immorality, idolatry, child sacrifice, etc. At the very least, the Lord had to warn them not to do these things (because they were prone to do them?). These people were a piece of work! But God's patience and grace were even greater. He will give them a land (23:9ff.) and plentiful harvests, he will provide atonement for them (23:26ff.), and he will be with them (ch. 24 and the tabernacle) and bless them (26:3ff.) if they will only turn to him.
The Lord just keeps calling out to Israel. Though they sin against him, he does not walk away. Sort of like he does with us. How wonderful is the Lord's patience and grace toward his people!
Come, ye thankful people, come,
raise the song of harvest home;
all is safely gathered in,
ere the winter storms begin.
God our Maker doth provide
for our wants to be supplied;
come to God's own temple, come,
raise the song of harvest home. -- Henry Alford (1844)