The sunglasses are mainly used to protect the eyes from the uv or other strong lights that could damage the eyes. Maybe there are some dangerous lights at raves. That is why many people wear sunglasses at raves. However, as the accessory, the sunglasses can really make them look cool.
It's hard to say why, maybe sometimes, they hate the way their eyes look when they are roll, they thought that it would be more comfortable and looks much better by wear sunglasses. And some people at raves wear sunglasses just for popping out, making them look special, cool and different from others.