The sentence, "Life is like a box of chocolate" has an important context. It is a line from one of the great movies of the last twenty years - Forest Gump. The whole quote is "Life is like a box of chocolate. You never know what you're gonna get." This is what Forest, the protagonist of the movie, repeatedly states.
The basic meaning of this quote is that you never know what life will bring to your doorsteps. In other words, life throws curveball, and the wise person will know this, and make the most of every opportunity.
An example of this can be seen in all of our lives. Things happen that we never expected - a loss of a loved one, a promotion, a visit from a friend, falling in love, and the examples can go on.