The problem here is invoking “chance” as if that was all that drove evolution. Evolution is an incremental process; new and novel structures almost never appear, but rather are adaptations of pre-existing structures. As to, say, the beauty of a butterfly’s wings, well even Darwin had observed that sexual selection, while not a form of utility from a pure engineering point of view, plays a significant role in many sexual species.
“Chance”, as in random mutation, genetic drift, sexual variation and other “engines of evolution” is a factor, but these are both constrained by environmental conditions, and are themselves not entirely random. A rather poor analogy is to imagine a spring bubbling up on a mountain. The route it may take to reach the sea is relatively random; as the land itself is random, but in the case of a stream, you have gravity as the major player. Water may take a very circuitous route to flow downstream, one that is essentially random, as dictated by the shape of the land that it has to traverse, but it will eventually reach the sea.
With evolution, the force at play really boil down to differential reproductive success. Environmental pressures are to populations of living organisms as gravity is to a river. You can’t necessarily predict the path any population may go down, but you do know that when you look at any extant organism, it has “reached the sea” by its ancestral population surviving and adapting (through multiple mechanisms) and passing on those genetic traits generation by generation. It’s harder to observe in more complex organisms like plants, fungi and animals, but it can be observed in much faster reproducing organisms like bacteria. Novel traits will evolve, including unpleasant ones like bacteria that evolve the ability to eat nylon or develop resistance to bacteria.