As you rub your finger on the rim, your finger first sticks to the glass and then slides. This stick and slide action occurs in very short lengths and produces a vibration inside the glass, which in turn produces a sound. As soon as the first few vibrations are produced, the water in the glass starts to vibrate and create one clear tone. You can change the pitch (highness or lowness of the sound) by adding to or subtracting from the amount of water in the glass. The volume (loud or quiet) can be changed only a little bit by increasing or decreasing the pressure from your finger.
Now, about the movement of the toothpick… this is caused by a sympathetic vibration. Because you’ve made sure both glasses vibrate at exactly the same frequency, the sound waves produced by the first glass travel in every direction. When those sound waves reach the second glass, the glass begins to vibrate as well and the toothpick moves. Is this a magic trick? Nope… just some really awesome science.