The Chinese idiom 塞翁失马 (sai4 weng1 shi1 ma3) literally means the old man on the frontier has lost his horse and comes from 《淮南子》 written by Liu An in the Western Han Dynasty.
once upon a time, there was an old man called Sai Weng who lived on the northern frontier of China. One day, his horse inexplicably disappeared. His neighbors and friends came to comfort him, but Sai Weng was not upset at all. He said
I have only lost a horse, and this is not a big loss. Maybe something good will come of it in future.
Sure enough, he was right. A few days later, his horse returned and it was accompanied by another horse that was even better. His neighbors came to congratulate him on his good fortune. But once again, Sai Weng had a different point of view. He said his good luck might turn out to be misfortune in the end. Strangely, he was right again. A few days later, his son fell from the new horse and broke his leg. But even this unfortunate event had a positive side too. Since his son was lame after that accident, he was not conscripted as a soldier to fight in the war and consequently lived safely with his family out of harms way.
Today, Chinese people use the idiom 塞翁失马 to comfort those who have suffered some misfortune. Effectively, they are saying
Don't worry, even the most unhappy situation may result in something good.
The English idiom (actually, an English proverb) that has a very similar meaning is every cloud has a silver lining. This English expression was originally used by William Shakespeare in one of his plays in a slightly different form
For every cloud engenders not a storm.