This is a very surprising statement from Joshua. Most likely Joshua wants to communicate the awesome nature of God’s holiness and jealousy, thereby encouraging Israel not to make bold commitments without serious reflection and thought. If you choose to serve the Lord, you must turn from other gods. He will not ignore you and allow you to do as you please, and serve him as an optional extra.1
19 But Joshua said to the people, “You are not able to serve the LORD, for he is a holy God. He is a jealous God; he will not forgive your transgressions or your sins.