“I trusted in You, Hashem, I shall not be shamed forever, and with Your righteousness You saved me” (Tehillim 31:2). This is as the passuk states (Yeshayahu 50:1), “Whoever among you fears Hashem and heeds the message of His servant, then even if he walks in darkness and there is no light for him, he can trust in Hashem and rely on his L-rd.”
When Am Yisrael enter batei kenesses and say to Hashem, “Redeem us,” then Hakadosh Baruch Hu says: Are there righteous and G-d-fearing people among you? And Am Yisrael answers: In the past, in the days of our forefathers, in the days of Moshe and Aharon, and in the days of Shaul and Dovid, there were righteous people among us. But now, due to our sins, they have been taken from us. As it says (Yeshayahu 57:1), “Because of the evil, the righteous man has passed away”; and it says (Tehillim 12:2), “For faithful, honest people have been eradicated from mankind,” and we have no one on whom to rely. For the longer we are in galus, the more troubles come upon us, “...when he walks in darkness.”
Hakadosh Baruch Hu tells them: Trust in My Name, and this trust in me will stand by you to save you from your troubles and to take you out of the galus, as it says, “He shall trust in the Name of Hashem” – for anyone who trusts in My Name, I will save him.
Chanayah, Misha’el and Azaryah trusted in My Name and I saved them, and so Nuvachadnetzar said to them (Daniel 3.28), “Blessed is the L-rd of Chananyah, Misha’el and Azaryah, Who sent His angels and saved His servants who trusted in Him.” And likewise Daniel, because he trusted in Me to save him from the lion’s den: “And Daniel was uplifted from the pit” – because he trusted in Hashem.
Dovid said: since this is the nature of bitachon, that You save those who trust in You; therefore, I place my trust in You.
(Based on Midrash Tehillim 31)