Water is made out of H2O molecules. These molecules are polar. This means that the electrons move closer to the oxygen nucleus (because the oxygen nucleus is heavier).In general , water can dissolve only polar and ionic compounds.So , by taking a look at the substance's structure(using something like X-ray spectroscopy or an electron microscope) , you can determine if it is polar , ionic or nonpolar substance( I won't get in much detail about the types of bonds there are), thus determining if it will disolve in water or not.