all for the best
Also, for the best. Best in the long run, despite appearances to the contrary. It is often a response to an unhappy outcome, as in They had to sell their business, but since they weren't making money it's probably for the best, or The dress had been sold when she went back, but since it was a little too tight it's all for the best. [Late 1300s]
Dictionary.com presents 366 FAQs, incorporating some of the frequently asked questions from the past with newer queries.