It's a tricky question at this point: the clicking sounds seem to be due to a natural increase of cavitation in the plant's stem. But it's hard to judge the extent to which the plant actually evolved to do this vs it being an accident with little selective downside. In the near future genetics might shed some light on whether an ancestor was too quiet/noisy and had increased pressure on relevant genes.
The disadvantages of too much noise are obvious (herbivores) but I haven't seen any convincing explanations on what the plant's advantage would be. There is some speculation on plant-plant communication, but maybe it is about attracting pollinators and seed-dispersers before the plant dies. Just a lot of stuff we don't know yet.
Selection mostly says losing traits tend to become rare, and winning traits more common. It doesn’t have much to say about benign traits. That which does not kill you makes you weirder.
Maybe in a situation where some plants are dehydrated and emitting sounds, and others are healthy and don't - having insects select one over the other helps spread the load a bit?