In your drawing, both electrons are at the right side of their atoms. It is not so. You can imagine the electrons orbiting around the atom very fast, so you can just observe an electron cloud. The electron can be anywhere along its orbit. So those atoms in the picture can have the two electrons at distance 1 from each other with the same probability of being at distance 4. And when they are very close, the repulsion force is very strong. Try to calculate with half electrons at both sides of an atom. :)
You will learn that temperature is connected to the kinetic energy of the molecules. When you heat up a substance, you increase the kinetic energy of its particles.
In case of a gas, the average distance of the molecules is determined by the vessel and the number of the molecules.
In a liquid or solid, the position of the molecules are determined by the attractive and repulsive forces. Their stable position is there where these forces cancel. But they still have kinetic energy, so they oscillate around the stable position, like two balls, connected to the ends of a spring. The total energy is constant, and farther from equilibrium, KE transforms to potential energy. At maximum distance from equilibrium, the KE is zero, and we call that distance amplitude. You know, the higher the energy of the oscillating body, the greater the amplitude, the farther apart can the balls (atoms, molecules) reach away from each other. You will learn, that the potential energy is not symmetric: it is easier to get away than to get close: In average, a liquid or solid usually extends at higher temperature.
All these explanations are oversimplified, as I do not know what you have learned so far. (There is an other important effect that contributes to repulsion: That the electrons can not be in the same states. It is called Pauli's Exclusion principle.
http://en.wikipedia.org/wiki/Pauli_exclusion_principle, I did not talk about).As you study Physics, you will learn and understand more and more about the behaviour of atoms and molecules, but we never will understand them fully.
ehild