Because the water's surface is not flat. The water has surface tension, which tends to pull the water up along the edge of the glass. In other words, the water around the edge is higher than the water in the center. The cork seeks (via the buoyancy force) the highest position, which is at the edge.
Perhaps we should have a forum (or reference links?) of interesting experiments, along with an explanation of how they work. Between us all we must know hundreds of great, but simple, experiments. I suppose that this would be hard to arrange though.....
We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling We Value Civility
• Positive and compassionate attitudes
• Patience while debating We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving