“To fathom something out”
What it means
To understand something after effort.
Where it comes from
A fathom is six feet, and to fathom water was to measure its depth with a knotted line. Sounding an unknown seabed is precisely the act the figurative sense describes.
How sure are we?
The literal nautical sense is older, and the figurative one follows it directly. Both are attested, and the metaphor of depth for difficulty needs no explanation in any language.