In the siddur Sefas Yisroel from OpenSiddur it is written:
שיר מזמור לאסף has been recited since the end of the Geonic period - a few hundred years before the introduction of the שיר של יום. Its first appearance in אשכנז was in the מחזור ויטרי,* most likely as a result of the צרות and גזירות that were imposed upon עם ישראל at the time.
And indeed it is mentioned by Emden and Heidenheim, and recited in Ungarn-Böhmen-Mähren communities as well (see this Anton Schmid or any Schlesinger siddur ad loc.) with a comment that it is not read on days, when Tachanun is omitted except for Chanuka and Purim. This theory is further confirmed by the fact that the book The Aleppo Codex by Matti Friedman reports (p. 37.) that this psalm was recited, when the Arabs attacked the Jews in Aleppo.
* However, it should be noted that instead of the last two verses (18-19) it continues with Yeshayahu 8:10, Psalm 5:11-12, 40:17 and so on.