"baitshopboy" --- to answer your question, a goby & pistol shrimp pair up because they benefit eachother mutually. In biology, they call this a symbiotic relationship. So, in the case of the Goby & the Pistol Shrimp, the Goby has better eyesight so can keep watch for predators. Hense the name Watchman Goby. The shrimp in return is better at burrowing the cave that they both use for protection. They rely on eachother's strength, so to speak, to increase their protection ultimately from nature's predators they face in the ocean. Facinating to watch in tank.
Since they Pistol Shrimp is close to blind, the Goby communicates with shrimp to retreat to cave by swishing its tail against the shrimp's antennae. All the while, the shrimp is constantly keeping their burrow cleaned and accessible.