blessing in disguise
A misfortune that unexpectedly turns into good fortune, as in Missing the train was a blessing in disguise, for if I hadn't, I wouldn't have met my future wife. [Mid-1700s]
The American Heritage® Idioms Dictionary Copyright © 2002, 2001, 1995 by Houghton Mifflin Harcourt Publishing Company. Published by Houghton Mifflin Harcourt Publishing Company.