the shrimp is blind or nearly blind...
watch closely and you will notice that the shrimp always rests one of his antenae on the goby when he is out of the cave. if there is "danger" the goby will twitch his body signaling the shrimp to dive back into the cave.