In general, for the substances that do not contain atoms/ions/molecules which absorb the visible light (i.e. most substances which contain neither transitional metals nor organic molecules with multiple bonds, and which are neither metals nor semi-metals, which have free electrons, nor semiconductors with very small bandgap, where the visible light creates free electrons), the condition to be transparent is that the substance must be in one of the following states: gas, liquid, glass (i.e. solid obtained by very fast cooling) or single-crystal (i.e. solid obtained by very slow cooling).

The reason is that in all these states, where the substance is fluid, amorphous or a single crystal, the substance is homogeneous, all the points inside it have the same properties, there are no internal boundaries, so light propagates in straight lines inside the substance, so light can pass through the substance, with only a pair of refractions on the external surface, when the light enters and exits the substance. Thus the substance is transparent.

Most solids, when they are neither cooled so fast to form an amorphous glass nor cooled so slow to form a single crystal, form at cooling a polycrystalline solid, e.g. like any rock or stone, which is made of a huge number of very small crystal grains.

In a polycrystalline solid, there is a huge number of internal boundaries, which refract and reflect the light. Therefore the light cannot propagate in straight lines, but in extremely long and intricate trajectories. If the substance is extremely pure, so nothing absorbs the light, it will be translucent, i.e. the light eventually gets out but you can not see any image of what is behind. Normal substances have some impurities that absorb the light. Due to the extremely long path of the light inside a polycrystalline substance, it will be eventually absorbed, so the substance is opaque.

So the difference between air, water, common glass, and quartz crystals versus most solids (which are neither amorphous nor single crystals) is that the former do not have internal boundaries, so the propagation of light is affected only at the external surface, while the latter have a huge number of internal boundaries, which reflect and refract the light.

The reason why the light is refracted when passing through a boundary between two different media can be understood without any knowledge about the nature of light, except that it behaves like a wave.

The light waves have different speeds on the 2 sides of the boundary. From the condition of continuity in time at a point on the boundary it results that the frequency of the waves must be the same in both sides, therefore the wavelengths must be different. From the condition of the continuity of the wavelength measured along the boundary on its 2 sides, it results that there must be an angle between the wave propagation directions on the 2 sides.

To explain why there is also reflection at a boundary, that is more complex, because the explanation needs some model of how light is absorbed and emitted and that depends on the chemical nature of a substance (some, like metals, reflect better than others).

Some simplified explanation is at

https://en.wikipedia.org/wiki/Reflection_(physics)#Mechanism