Origin and meaning of "every cloud has a silver lining"

Solution 1:

According to The Oxford Dictionary of Proverbs, the phrase "Every cloud has a silver lining" is

a poetic sentiment that even the gloomiest outlook contains some hopeful or consoling aspect. Cf. [1634 Milton Comus I. 93] Was I deceiv'd, or did a sable cloud Turn forth her silver lining on the night?

Read more: http://www.answers.com/topic/silver-lining#ixzz1Cu5fvfWP and http://www.etymonline.com/index.php?search=silver+lining&searchmode=none

Both cite John Milton's Comus 1 as the first instance of this expression.

Solution 2:

The idea of clouds having silver linings comes from the fact that when the sun (or moon) bursts through a cloud it looks as if the interior is silver.

The sun bursting through a cloud is a good metaphor for a problem eventually having a positive outcome.