Only some glass is close to being transparent. The part that we left unexplained is why the index of refraction is nearly uniform in most glass. Actually, that's true for most liquids and solids. If there were a little region with lower-than-average density, it would quickly fill up. So most liquids (water, alcohols, organic solvents, ...) are transparent unless they happen to contain some molecules that have just the right energy gaps to absorb visible light. Glasses are very similar to liquids in their molecular arrangements. They're packed a little more tightly, which helps account for why they can't easily flow. That means that they generally have even smaller density fluctuations than do similar liquids. So there's nothing to scatter the light. A pure crystal (quartz, for example) has a regular array of atoms, so it has even more uniform density than does a chemically similar glass (fused silica). Still, the glass is uniform enough not to scatter much.