This quote can be taken as general wisdom about life, or looked at in the specific context of Martin Luther King Jr.'s life.
As a general insight, this wise advice can be applied to anything in life. When things go wrong, or we are in a negative situation, the disappointment is always temporary. However, while disappointment comes and goes, we can always have hope, which helps us to get through hard times and strive towards better things.
MLK was a leader in the Civil Rights Movement, and this quote could also be describing his experience with political activism in that time. As anyone advocating for change will understand, there are usually a lot of setbacks, disappointments, and answers of "no" before anything positive gets done. MLK dealt with a lot of hatred, racism, and refusal to change before he impacted the world for the better. However, he always had the hope that he could eventually achieve this change, and that is what kept him pressing on.