The reason for this has to do with the way that light interacts with matter. When light hits an atom, it can either be absorbed or scattered. If it is absorbed, the energy of the light is transferred to the atom, causing it to vibrate or emit other types of radiation. If it is scattered, the light is simply deflected in a different direction.
The probability of light being absorbed or scattered depends on the wavelength of the light and the type of atom. Visible light has a relatively long wavelength, so it is not as likely to be absorbed or scattered by atoms as shorter wavelength radiation, such as ultraviolet light. This is why we can see through the universe, but not through a brick wall.
There are a few other factors that can affect the transparency of the universe. For example, the presence of dust and gas can scatter light, making it more difficult to see distant objects. The expansion of the universe can also cause light to be redshifted, making it more difficult to detect.
Overall, the universe is a very transparent place. This is why we can see the stars and galaxies that are billions of light-years away. However, there are some factors that can affect the transparency of the universe, such as the presence of dust and gas and the expansion of the universe.