Joshua 23:6 “Be very strong; be careful to obey all that is written in the Book of the Law of Moses, without turning aside to the right or to the left. 7 Do not associate with these nations that remain among you; do not invoke the names of their gods or swear by them. You must not serve them or bow down to them. 8 But you are to hold fast to the Lord your God, as you have until now.

9 “The Lord has driven out before you great and powerful nations; to this day no one has been able to withstand you. 10 One of you routs a thousand, because the Lord your God fights for you, just as he promised. 11 So be very careful to love the Lord your God.

This is from the easy English site.

Verses 6-10 Joshua also gave several instructions to the people.
Be strong.
Obey God’s instructions.
Do not become friends with God’s enemies.
Do not worship false gods.
Love God.

This is from the site.

They need to be courageous so they can be obedient. Following God and His word isn't something for the faint of heart.

They must do all that is written in the Book. We tend to focus on the aspects of obedience that we like and skip over the parts that attract us less.

They must not turn aside from it to the right hand or to the left, because Satan doesn't care which extreme he gets us off to. Either legalism or licentiousness please him.

There isn't a lot of commentary on these verses. It must be pretty self-explanatory. Joshua told them, the key to success is God. It's not an easy key to keep as a human.... we tend to get sidetracked by shiny trinkets and strange ideas.