"Every cloud has a silver lining" is an idiomatic expression in English meaning that there is usually something positive to be found in every situation, even when it seems overwhelmingly negative. Taken literally, it means that even when a cloud passes in front of the sun, it is still often possible to see a glow around the edges of the cloud from the sun shining behind it. In life, the phrase is often used to encourage people to keep going and make an effort to look for the good things that might have come out of a bad situation. For instance, perhaps losing a job allowed someone to go back to school or find a job they like better, which would be the "silver lining" in that situation.
A variation of this phrase was first written as "Was I deceived, or did a sable cloud Turn forth her silver lining on the night?" in John Milton's in "Comus: A Mask Presented at Ludlow Castle, 1634." It was then rephrased, referring to "a silver lining to every cloud," and found in The Dublin Magazine in 1840. The simple expression remains fairly commonly used to this day.
It is important to be considerate when using this phrase, however. Some people might be upset if they feel a person is trivializing their bad news by saying "every cloud has a silver lining," when a sympathetic or empathetic response might be more appropriate. It is necessary to use good judgment before simply saying this phrase to someone if they encounter misfortune. Usually it is a good idea to wait until something good actually has come from misfortune before reminding people of it, or at least to give it a little time.
In many cases, however, saying "every cloud has a silver lining" can remind someone that all is not lost, and even though they may feel bad today, they can, and should, look for opportunities to feel better. Unfortunate events often serve as the catalyst for for better things to happen, such as finding a new job or a better relationship after the loss of the old one, for example. At the very least, it is a helpful reminder to try to look for the positive rather than dwelling insistently on the negative in any situation.