Well, first and foremost, your torques have to be balanced.
Check out this picture I made. It's a top-down view of a tray with four drinks on it. Imagine the center is where the waiter's hand is.
Torque, if you didn't know, is a "twisting force". The torque that a glass of water exerts on a tray is equal to the weight of the drink, times the distance it is away from the center.
In order for this tray to be balanced, all four torques have to add up to zero.
As a simple example, if you have a 10 Newton object, 40 cm away from the fulcrum of a balance beam, where should you place a 25 Newton object in order to balance it? To see it as an equation, (10*40)+(25*x)=0. If you solve for x, you find out that x= -16, meaning that you should place the 25 Newton object 16 cm away from the fulcrum, on the opposite side.
The picture above is a little more complicated, because you're balancing torque in more than one direction. All you have to do, is break each distance vector into its x and y components, multiply each component vector by the weight of its glass, and do the balance beam problem, once in the x direction, and once in the y direction.
Another important factor is the shape of the glass itself. As you suggested in your post, a taller glass is harder to keep standing. This is because it has a higher center of gravity than a shorter glass. A glass will start to fall over once its center of gravity is tipped passed the base of the glass.
The glass on the left only has to be tipped 15° before it starts to fall over.
The glass on the right has to be tipped a whole 45° before it starts to fall over.