Why does it say "Tov Hashem l'Ma'oz"?
Rashi (from Mechilta Shirah 4): Even when He takes payment from His enemies, His mercy does not budge from benefiting those who fear Him. This is unlike a person ? when he engages in one matter, he is not free to engage in another. It says "Hashem Ish Milchamah Hashem Shmo" (Shemos 15:3).
Radak: This refers to the end of the verse. Hashem is good to Yisrael, who trust in Him. He will be a fortress for them on the day of affliction of the kings of Ashur. Even though Malchus Ashur will be destroyed, Yisrael, who are exiled in Ashur's land, will escape Nebuchadnetzar's sword.
Malbim: The previous verses imply that the entire earth will perish. Where will people stand? It answers, on a day of affliction, it is good to stand on Hashem ? He is the place of the world. The creations will find refuge in him.
What is the meaning of "v'Yode'a Chosei Vo"?
Rashi: He knows the needs of those who trust in Him.
Radak: He knows [those who trust in Him] for good and oversees them. This is like Ki Yode'a Hashem Derech Tzadikim" (Tehilim 1:6). Chosei is Samuch, even though a preposition follows it. We find like this ? "Kol Chosei Vach" (ibid. 8:12), "Harei va'Gilbo'a" (Shmuel II, 1:21), Gemulei me'Chalav" (Yeshayah 28:9) and similar verses.
Malbim: This fortress (Hashem) is better than natural fortresses, which do not know those who take refuge in them. Hashem knows those who take refuge in Him, and supervises them with Hashgachah Pratis. In this Churban of the Klal, Hashem will oversee with mercy those who trust in Him, and save them from affliction.