Well historically I suppose it goes back to the early days of commercial aviation where civil aviation found its roots in the military?
In an airline it's a visible indication of rank - and in any other situation which pilots are expected to manage.
But in this modern world why not just wear a smart uniform/suit ... ?
Hats have disappeared, so why not ties and insignia ... ?
It has a lot to do with tradition where people in an hierarchical environment are expected to show badges of rank - whether that be the military, the Police or officers at sea or in the air.