Let’s say I want to shoot a static scene and have a free hand regarding the focal length. If I ignore the geometric distorion for a while, do I get some image quality advantage by shooting from a closer distance, using a shorter focal length? Is there a difference at all? (I am primarily interested in the differences in detail.)
Theoretically, assuming two perfect lenses, which do not distort the image at all, but just achieve different fields of view, then the wider angle, from closer should have better image quality, assuming a perfect collection surface (sensor or film). Reasons for this would be less air to disperse the light between you and the subject, and less air for differences in temperature/pressure/density/water content/particulate matter content to cause refraction and get in the way of the straight path of light.
However, no lens is perfect or sensor is perfect, so the effect is certainly not at all relevant or noticeable for moderate distances, it starts to become practically relevant when using very long lenses, such as the Canon 1200mm. The effect of optics also needs to be considered, as well as the effect of distortion, so overall, there are many factors that have MUCH more effect than distance on image quality.