You are correct that they will always try to be as far apart as possible. However, there are constraints on what is possible. For example, why do they not move infinitely far away from each other? That seems obvious: it's because of the strings. But more generally, the strings are creating a force that works to prevent them from moving away. If you had some incredibly large charges on each ball, the strings would snap and the balls would begin to move away from each other.
The reason that they don't move 180˚ apart is that gravity is also acting on the balls in a downward direction. Usually the charge is not large enough to push the balls that far apart. To do so would require that the repulsive force between the balls be much more important (that is to say larger) than the effect of gravity. The force between the balls relies directly on the charges on the balls and the distance between them and typically is not large enough to push them that far apart.
However, if we look at things at the very small scale (molecules), we can see that they do something similar to what you're asking. CO$_2$ is a molecule with one carbon atom in the middle, an oxygen atom on either side and no unpaired valence electrons. If you look up a diagram of CO$_2$, you should find that it is drawn as a linear molecule. The oxygen atoms push against each other to try to move 180˚ apart. However, they are still tethered to the main carbon atom so they can't move further apart. In this case, you would find that the force of gravity on each oxygen atom is extremely small compared to the repulsive force they exert on each other due to being very close together. The fact that they have very little mass, and thus are much less affected by gravity is an important distinction between the two cases.