Lines 2-6 of this song repeat a fragment of the 57th Chapter of Tehillim (see lines 8-12). Lines 7-12 are taken from Chapter 60 (7-14).
Malbim adds that this song was composed to emphasise the parallel between the events in the life of David (57th chapter) and in the history of the whole nation (60th chapter).
In both cases, people who found themselves in seemingly hopeless situations, were saved by the Almighty.
By reciting Chapter 108, people will remember both the miracles which happened to David, and the miracles which happened to the people of Israel.