The transaction recorded in these verses may be regarded as the solemn inauguration of Joshua to the office to which he had some time before Numbers 27:22 been called, and his recognition in it by God, which were manifested by his being summoned into the tabernacle with Moses while the Lord appeared in the pillar of cloud (compare Numbers 11:25; Numbers 12:5).
Deuteronomy 31:16
The future apostasy of the people is announced in the presence of Joshua that the latter might be fully aware of the danger and strive in his day to avert it. This he faithfully did (compare Joshua 24:31); but we find him in his own last address to Israel repeating Joshua 23:15-16 the self-same prediction and warning.
Deuteronomy 31:19
A witness for me against them - i. e., an attestation from their own mouths at once of God‘s benefits, their own duties, and their deserts when they should fall away. Being in verse it would be the more easily learned and kept in memory. The use of songs for such didactic purposes was not unknown to the legislators of antiquity. Compare also the advice of Paul, “teaching and admonishing one another in psalms and hymns and spiritual songs” Colossians 3:16.
Deuteronomy 31:23
He gave - i. e., the Lord gave.