Note: the camera that so clearly wins here, the 5D, is a 3-year-old model that is hopefully to be soon updated.
The difference between the $500, cropped-sensor lens (EF-S 17-85) and the $1,000 L lens (EF 24-105) is probably the greatest factor.
If one is mainly going to do portraits or photograph art, for example, great results would probably be achieved with the 40D (or a late-model Rebel) with the $90, EF 50mm f/1.8 lens.
In this test I thought I’d compare two “walking around” outfits. By “walking around” I mean using a single lens that covers the wide to short telephoto range, preferably with Image Stabilization. It’s the sort of lens you might carry with you on the camera if you didn’t quite know what you wanted to shoot, for example while walking around a city on vacation or taking a walk along the seashore.
With the Canon EOS 5D, the obvious choice is the EF 24-105/4L IS. It covers a good range of focal lengths, it’s fairly fast at a constant f4, it’s an “L” series lens so its quality should match the EOS 5D and it has image stabilization.
For the EOS 40D, the obvious choice was the EF-S 17-85/3-5.6IS. This gives the same angular field of view coverage as a 27-136mm lens would on a full frame camera like the EOS 5D, so it doesn’t give quite such as wide field of view as the 24-105 on the 5D, but it has a longer telephoto reach. Again it’s a lens you might carry around when you weren’t quite sure what you’d be photographing but wanted to cover a fairly wide range of focal lengths.