The fundamental theorem of Galois theorem states that for a finite Galois field extension $E/F$, there is a one-to-one correspondence between the fields $K$ with $F\subset K\subset E$ and the subgroups of the Galois group $Gal(E/F)$ of the field extension $E/F$. I think this correspondence can be considered as an equivalence of categories if we consider the category of intermediate fields together with field homomorphisms fixing $E$ and the category of subgroups together with morphisms of corresponding $Gal(E/F)$-sets. (The details won't matter for my question.)
The Stone duality states that the category of Boolean rings is equivalent to the dual category of the category of zero-dimensional compact Hausdorff spaces.
There are many more one-to-one correspondences between different sorts of mathematical objects (Pontrjagin duality, Gelfand duality, ...).
My question isn't a precise mathematical one, but rather a soft-question: How on earth were such crazy correspondences discovered? Concerning the first example, I agree that both groups and fields are natural concepts to study, but I would never ever get the idea to conjecture that there is a correspondence between such-and-such groups and such-and-such fields, because fields and groups are rather different animals. Same with the second example. Rings are one thing, coming from algebra. Hausdorff spaces are quite another thing, coming from topology. How to even conjecture that there is a connection between the two?
I would be interested in rudimentary historic answers, but to me getting any clue on how one could have stumbled across these things matters more than historic correctness.