The purpose is to worship Yahweh and rejoice in all the good that he has done for Israel, their house, the Levite, and the foreigner among them.