This is very complicated. Chemical bonding is a hard topic and physicists nowadays don't like to talk about it so they leave it to chemists =)
Here's my explanation which may be helpful, assuming you know a bit of quantum mechanics... it gets kind of long though so please be patient.
Lets not start with H2O. That's pretty complicated. It has 10 electrons and 3 nuclei. Instead let's start off with H2. But that's still too complicated since it has 2 electrons that repel each other. Indeed, let's go with H2+ - 2 protons and an electron. That's the simplest possible molecule.
First we apply the Born Oppenheimer Approximation - the nuclei are stationary. This seems obvious but its subtly not so - the electrons are after all negatively charged and should pull the positively charged hydrogen nuclei right? But since the nuclei are really big and heavy compared to the electron (2000x), we'll just say they don't move. In terms of quantum mechanics, we can separate the molecular Hamiltonian into a nuclear Hamiltonian and an electronic Hamiltonian.
The dynamics of the molecule is determined by the electron motion alone, after all nuclei don't participate in chemical bonding. We write this as the electronic Hamiltonian He = -h^2/2m * ∇^2 - e^2/rA - 2^2/rB + e^2/R
where ∇^2 is the Laplacian operator, R is the internuclear distance, rA is the distance between nucleus A and the electron, and rB is the distance between nucleus B and the electron.
So now we write the Schrodinger equation: He ψ = Ee ψ where ψ is the electronic wavefunction. This can be solved, but its really complicated, so we use a trick to solve it approximately.
We know for a fact that if R increases to infinity, the "molecule" actually becomes a hydrogen atom + a lone proton. So let's say the electron was closer to nucleus A.
Then it would have the same wavefunction as a ground state hydrogenic electron:
ψA = constants*e^rA/a0 where a0 is the Bohr radius and the constants are important but ultimately just constants so they don't impact the dynamics of the system.
If the electron was closer to B, similarly:
ψB = constants*e^rB/a0
So as a first approximation let's just say that the molecular wavefunction is the summation of these 2 atomic wavefunctions: ψM = C1*ψA + C2*ψB where C1 and C2 are just random constants.
Now, we could use the variational method... but that's too mathematical. Instead, let's use a trick: we know that the nuclei are identical, so the electron distribution must be symmetric! The only way for this to happen is the absolute values of C1 and C2 are the same, otherwise the electron would spend more time at one of the protons despite both protons being identical! So |C1| = |C2|.
The probability distribution for the electrons are therefore (ψM)^2 = C1^2*ψA^2 + C2^2*ψB^2 + 2C1*C2*ψAψB. Note here that C1 and C2 are squared. That means it could be either positive OR negative and yield the same answer, so C1 actually is = +/- C2.
So the molecular wavefunction is actually 2 wavefunctions:
ψM+ = C1(ψA + ψB) and ψM- = C1(ψA - ψB) corresponding to the 2 cases I discussed above.
Skipping some math - you should define an overlap integral S = ∫(ψAψB)dr ... yeah forget about it, that's not too important and it ends up being constants anyways.
When you take the 2 wavefunctions and plot them on a graph, you'll find this:
For ψM+ the wavefunction is very low far away from both nuclei and hit a peak at the nuclei. Between the nuclei, there is a residual "bridge" of wavefunction, so when ψM+ is squared, there is a nonzero electron probability distribution between the nuclei. That's the bonding orbital.
For ψM- its still very low far away from both nuclei, but since the B nucleus has a negative coefficient, the wavefunction there is negative. Note, because the wavefunction at A is positive, and at B it is positive, it had to cross ZERO somewhere between A and B. Therefore, when you square it, there is a point in the graph that is ZERO and has NO ELECTRONS there. That is the anti-bonding orbital.
Now note that we had 2 ground state atomic orbitals and it transformed into 2 molecular orbitals, one bonding and one anti bonding. Anti-bonding orbitals have higher energies than bonding orbitals. Each orbital can hold a maximum of 2 electrons, due to the Pauli Exclusion Principle.
So we have 1 electron. It goes into the bonding orbital. That's great. But why do we see H2? Well, H2 has 2 electrons in the bonding orbital, which makes the chemical bond more stable, but none in the anti-bonding orbital. If we add a 3rd electron, it destabilizes the chemical bond a bit. But since there's electrostatic repulsion in H2-, the 3rd electron can never be added, and since there's electrons just floating around, in practice H2+ always will get the 2nd electron, only the most stable configuration is seen in nature, though H2+ can be produced artificially.
So in water the same thing applies, oxygen has 2 free "electron slots" in the p2 orbital, the 2 hydrogens donate an electron to oxygen, and since the anti-bonding molecular orbitals aren't filled, and no more bonding orbitals can be filled, H2O is stable.
References if you want to look further: "Quantum Chemistry" Ira Levine