>>13288457Barnacles already can attach to basically anything, such as whales or ships for instance. Attaching into living (or moving anyhow) things improves their chances of reproduction as the host carries them to new areas. At first there were probably small barnacles that grew on the crabs, the better one could attach to the crab the better your chances of reproducing and spreading as the crab carries you to new sites. Initially they probably only grew on the outside or in the crevices but an easy way to attach is to simply burrow roots into the crab which is again only a short step away from altering the host behavior trough invasive burrowing or hormones. Once that could do these things out competed the previous inferior barnacles and transformed closer to the modern parasite we see today.
Obviously I don't actually know and the process could have been different, perhaps genetic study of the thing could yield more results but then again it might not. It's always hard to say why things happen the way they did, you just have to accept they happen and look for logical ways to explain them.