It indicates a gross mistake, the achievement of a much lower result than hoped for or, more rarely, purchasing something believing it to be of much higher value than it actually is.
This expression, among the most common used in Italian to indicate a mistake, has its origins in fishing , particularly sport fishing. If you lower the line into the sea until you reach the seabed and touch the bottom with the hook and the bait, it may happen that a crab bites instead of a fish . As soon as the crustacean is hooked, it immediately begins to struggle violently to free itself from the hook, giving the fisherman the impression that it has instead hooked a large prey.
Fishing for a crab with a rod is normally a source of disappointment for the fisherman, since it is a useless prey, which in some cases can even damage the line. The origin of the phrase was born from this disappointment, generated by the expectation of a large fish.
italian has prendere un granchio, lit. meaning, “to catch a crab”.