means that
even an unpleasant or difficult situation may contain an unexpected benefit or reason for hope.
also
Every dark cloud has a silver lining.
When every difficult or unpleasant situation has some advantage, it can result in some benefit to you., the saying “Every cloud has a silver lining” is appropriate.