blessing in disguise
when something appears to be bad at first but turns out to be a good thing in the endContext:
-I think being caught in that traffic jam was a blessing in disguise.
-Oh, yes! If I hadn't missed the flight, I would have been on that plane when it crashed!