Octanol is a polar molecule, like water is, while octane is a nonpolar molecule. Since octanol and water have the same molecular polarities, based on "like dissolves like", octanol will dissolve in water. On the other hand, octane and water do NOT have similar polarities, so octane will not dissolve in water.
Based on like dissolves like and the fact that water is a polar molecule, only POLAR molecules will dissolve in water, since molecules have the same polarity as water to dissolve in it. On the other hand, nonpolar molecules will NOT dissolve in water, since they have different molecular polarities from water.