When you talk generation to generation, the gradual tiny mutation each time did indeed allow primates to grab the branches a little better and so they had a higher rate of survival and the causation matters.
But when you talk about the end product (the hand), it is fair to say that primates (as the product of those millions of tiny iterations) evolved to better grab branches, imo.
But on the other hand, some of the kludginess is also bloody amazing. Spiders, for example. The gut passes through the "brain". So there's a tradeoff between "brain" size and eating. And so they employ external digestion, and suck liquid.
The first part is that brains are just plain weird, and perhaps one of the weirdest aspected of any multicellular organism. More than half of all known life forms don’t have brains. So, brains usually aren’t a priority.
Second, the gut is often regarded as a brain-like organ in many vertebrates, and so, with arthropods and crustaceans, it’s interesting that the the two might be more tightly coupled. It probably cheapens the endocrine feedback loop.
Third, external digestion actually comes across as less freakish and uncivilized underwater. On land it has a messy, disgusting sensibility, but in the ocean it’s kind of on par with a smokey cooking fire at a camp site, especially when considered from a single celled animal’s perspective.
When you consider that crabs and lobsters are the ancestral relatives of insects and arachnids, the low prioritization of a brain, and externalized digestion start to look more and more normal.
In all invertebrates, "brains" (to the extent that they're present) are ring ganglia, with the gut going through the center. So arguably they all face that tension between brain development and the ability to eat. Vertebrates, conversely, have ~parallel guts and central nervous systems, so there's no conflict.
The thing with octopuses is that their ring ganglia are mode widely spaced. Having no exoskeleton helps with that, I guess.
We agree that it can be difficult to distinguish causation from correlation, and in this case you may be right that the survival advantage conferred by better grasp of branches might have been a "bonus" or helpful side-effect, rather than an adaptive trait directly informing our ancestors' evolution. But I don't think it's so clear-cut or obvious.