To answer this question we need to know what makes glass different to air. The main difference is their refractive index. For air it's 1 and for glass it's anywhere between 1.52 - 1.54 depending on the type of glass. Higher refractive index means it's harder for light to pass through. When we say "harder" we usually mean the speed of the light decreases, it moves slower because it's finding it more difficult, glass is denser, it's got more particles. (As a side note, the speed of light is always constant at 30 million meters per second, the reason why the speed "decreases" is a bit more advanced and we will not go into it. The speed of light appears to have decreased is more accurate) . The short answer is, light gets refracted in glass, because it's speed decreases.
What would happen if light was travelling from glass to air? well, it's speed would increase.