Absorption of sunlight by gases in our atmosphere happens when a particular frequency of the Sun's electromagnetic radiation is similar to that of a vibrational frequency of a particular gas molecule in the atmosphere. read more
Our atmosphere is largely transparent in the visible light part of the spectrum because of the lack of suitable molecular vibrational frequencies for absorption. However there is considerable absorption of ultraviolet (by ozone) and infrared (mainly by water vapour and carbon dioxide and other “trace gases” such as methane). read more
I also notice other planets in our neighbourhood weren't quite so lucky. but assuming you're talking about Venus, Jupiter, Titan etc, the scattering is from particles not from gases. After all, Earth's atmosphere isn't particularly transparent on a cloudy day. It is a co-incidence that the Sun's light peaks in the visible region. read more