By design, evolution optimises for survivability. Survivability is composed of two major things-
organism surviving itself by way of basic needs like food, shelter, safety, etc.
passing of the genes by way of reproduction
Reproduction in a bulk of organisms happens by way of sexual reproduction that requires mating partners (most of the times).
In order to attract mating partners, species of different organisms develop traits and techniques to signal to their sexual counterparts to participate in reproduction.