13 Now when Joshua was near Jericho, he looked up and saw a man standing in front of him with a drawn sword in his hand. Joshua went up to him and asked, “Are you for us or for our enemies?”
14 “Neither,” he replied, “but as commander of the army of the Lord I have now come.” Then Joshua fell facedown to the ground in reverence, and asked him, “What message does my Lord have for His servant?”
15 The commander of the Lord’s army replied, “Take off your sandals, for the place where you are standing is holy.” And Joshua did so.
In Exodus 3:5, Jehovah God said exactly the same word to Moses in the burning bush;
"Do not come any closer," God said. "Take off your sandals, for the place where you are standing is holy ground."
First I will introduce the Matthew Henry’s commentary on these verses that I like to take;
We read not of any appearance of God's glory to Joshua till now. There appeared to him one as a man to be noticed. This Man was the Son of God, the eternal Word. Joshua gave him Divine honours: he received them, which a created angel would not have done, and he is called Jehovah, chap. 6:2. To Abraham he appeared as a traveller; to Joshua as a man of war. Christ will be to his people what their faith needs. Christ had his sword drawn, which encouraged Joshua to carry on the war with vigour. Christ's sword drawn in his hand, denotes how ready he is for the defence and salvation of his people. His sword turns every way. Joshua will know whether he is a friend or a foe. The cause between the Israelites and Canaanites, between Christ and Beelzebub, will not admit of any man's refusing to take one part or the other, as he may do in worldly contests. Joshua's inquiry shows an earnest desire to know the will of Christ, and a cheerful readiness and resolution to do it. All true Christians must fight under Christ's banner, and they will conquer by his presence and assistance.
God is not always on our side. He is on the side of Jesus. Jesus is for us, but He serves God and is the Commander of the army of the Lord. If we are on the side of Jesus, then God is on our side.
Christ is the Supreme Commander and Author of our salvation. Let’s follow Him all the way to Heavenly Gates! Amen.