This expression describes a situation in which a person can enjoy the positive aspects of two different opportunities – without missing out on either.
For example, “The mother enjoyed working part-time because she could spend time with her children after they finished school and enjoy working and meeting other adults. She had the best of both worlds.”
In this situation, the mother has the positive aspects of: 1) Being a stay-at-home mother - i.e. spending time with her children, and 2) Being a working mother - i.e. working and meeting other adults.