Most things get a little bigger when they are heated, even though you probably cannot notice it. If you were to place a glass in a pan of water and heat the water slowly, all the surfaces of the glass would expand evenly, making the whole glass a little bigger.
But if you pour boiling water into a cold glass, the inner surface of the glass gets the heat first and expands more quickly than the outside. The pressure from this heated, expanded inside surface is so strong and so sudden as it hits the outside of the glass that the whole glass breaks.