What sets the angle...?
The fact that the hydrogen atoms have a fairly strong positive charge and the oxygen is a strong negative. If the molecule were linear, the hydrogens would create a double-positive (positive on both ends) and there would be no clear negative. But with the "bend" in the arrangement, the oxygen serves as the negative pole and the hydrogens as the positive, giving the molecule its polarity and its power as a solvent, its freezing characteristics, and its relatively high boiling point. It also ionizes completely, which is critical to the transport of nutrients into and out of living cells.
Three simple atoms, and the most elegant of substances.
Random chance? I don't think so.