There are many reasons why an organism might have a trait that does not appear to be beneficial.
The trait is actually advantageous even if it does not appear to be.
The trait is a byproduct of another trait, which is beneficial. Not all traits are the product of direct selection; traits that are byproducts of other traits are known as "spandrels", a trait coined by Stephen J. Gould and Richard Lewontin
The trait was fixed by some process other than natural selection, such as genetic drift. Genetic drift can fix traits that are neutral or even evolutionarily disadvantageous.