A blessing in disguise

When something bad happens at first we do not see that there are also good points in the situation.

Examples

He missed the bus and it was a blessing in disguise. That bus got into an accident.