This idiom means that you should be optimistic, because things will get better or you. It also means that good things could happen out of bad things.
Example:
I can’t believe that I lost my job!
Maybe, you will get a better job. Every cloud has silver lining.