If you look at the electron configuration for oxygen - atomic number of 8 - it has two electrons in the first energy level (1s), with the remaining 6 in the second energy level. Two of these are s-type electrons and the remaining four are p-type electrons. If you draw a Lewis diagram for oxygen you find that there are two pairs of valence electrons, and two single electrons available for bonding. Because of the two pairs of electrons this repels the two single bonding electrons into the 105 degree angle which is found in water. The non-linear molecule has a very negative region. In addition, because of the strong attraction of the oxygen nucleus on the surrounding electrons, there is a dipole establilshed between the oxygen atom (negative) and the two hydrogen atoms (positive) bonded to it. The result is a strong electrical attraction between the negative oxygen atom and the positive hydrogen atoms of adjoining water molecules.
This is due to the difference in electronegativity of H and O.
Electronegativity is the relative tendency of an atom in a bonding to attract the bonded electron pair towards itself. Greater the value of electronegativity, greater the tendency. In Pauling Scale of electronegativity the maximum value is for Fluorine = 4.
In water the electronegativity value for O = 3.5 and for H = 2.1
Due to this difference, oxygen will attract, the H--O--H electon pair between oxygen and two hydrogen atoms, towards oxygen and become doubly negatively charged. So the two H aoms are positive charged.
This charge seperation, resulting from the difference in electronegativity, is the reson for the polar nature of water.
We can see that H-H (hydrogen molecule) or O=O (oxygen molecules are non-polar because the difference in electronegativity of H-H, or O=O, in these type of molecules are zero.