Let's see an illustration of a water molecule:
You can see that the oxygen has two pairs of electrons free representing a partial negative charge. These partial negative charges don't allow the molecule has a linear structure. All of the electron pairs—shared and unshared—repel each other and that's why the water molecule has a bent shape, because of these unshared electrons of oxygen.