We are barely able to see Mars with our eyes and at most we get to see stars in distant systems; However, we can know which atoms are contained in the atmosphere of other planets beyond the solar system. Let's see what science hides this apparent magic.
Obviously planets like Venus or Mars are close enough to be able to send a probe to explore them and analyze the chemical composition of their atmosphere, even Pluto can be reached in a reasonable time. But when what we want to analyze in the atmosphere of other planets that are hundreds or thousands of light years from us, the thing becomes more complicated. Of course, sending a probe is not practical since we will most likely disappear as a species before it reaches this planet.
We have no choice but to look, and try to be able to see what composition that atmosphere has. Considering how complicated it is to see a tome on Earth, it sounds impossible to see the atoms that move in the atmosphere of other planets and if we want to use our eyes or devices to look in a conventional way it is impossible; The key is to look in a more scientific way and observe not only the light that reaches us, but the traces that the planet that interests us has left on that light.
The key is not in seeing the light, but in seeing what the light is like
The really curious thing is that each tome only absorbs and emits light in some particular frequencies, what is known as its absorption or emission spectrum. This is the equivalent of a DNA test on an object, with the difference that since we only need to illuminate it, we can do it thousands of light years away. In short, when light passes through a medium, even if it is transparent, it undergoes changes and transformations that give us information about the composition of the material it has undergone. By detecting this light once the gas has passed through we can know what atoms are in the atmosphere of other planets.
Light not only tells us about the atmosphere of other planets
This has a small problem: light as it passes through space changes its frequency due to gravity (to the curvature of space-time if we want to be precise), and can even increase or decrease its frequency depending on the speed have the body that emits it. One would think that this is horrible since it only confuses and spoils the measurements, but the reality is that this effect (especially the last one) is a mine of information. To measure the composition of the atmosphere of other planets is not a big problem since the spectra of gases (the light they emit) are so special that only knowing the distance between the absorption or emission lines we can identify the compound.
And now let's return to the advantages of light changing frequency depending on the speed of the material that light emits (this is what is known as Doppler effect). If we are able to identify the material, we will know how much the frequency of light has changed in its path and, therefore, we will be able to calculate the speed of the emitting object. This we have already told you in more detail, but using the Doppler effect we can know up to the speed of rotation of a star that is thousands of light years away!