há males que vêm para o bem

Etymology
lit. 'there are evils that come for the good'.

Proverb

 * 1) A negative event may have a later positive effect.
 * 2) An overall negative event may have a positive side effect.
 * 3) Nothing is wholly bad.
 * 4) Enduring negative experiences will eventually pay off.