There are dozens of ethnic minority groups in China have their own folklore: much of which contains valuable historical and cultural information as well as many unique myths.
Historic Chinese Legends, Tales and Idioms » Sai Weng Shi Ma – A Blessing in Disguise
This idiom indicates that something seemingly bad may turn out to have been a good thing in the end, a blessing in disguise. The story in the video explains it quite well. And, while the idiom can also have the opposite meaning (a good thing becoming something bad), the former is more frequently used.