Blessing in disguise
A blessing in disguise is a good or fortunate outcome from an ostensibly bad or adverse situation, and according to the OED is first cited from 1896.