Hopelessness drives a person into deep depression. Jeremiah felt the pain of the punishment of those who were guilty. He'd lost all hope and was at the bottom of the barrel. When you're at the bottom of the barrel, all you can do is look up.
When we're down and depressed, we need to renew our mind! You can think yourself down into depression and despair. Jeremiah remembered all that had happened in the past, but also recalled the goodness of God. He dwelt on the tiny ray of light he had. As we see in this passage, your mindset changes when you think on the Lord. Jeremiah's theology became a doxology.