The 5D is 12.8 MP, 40D is 10.1 MP. The 5D has a better build quality - better weather sealing, shutter rated to 300K, not 100K. As a result, it is double the price.
But unless you are a serious pro photographer, probably the main difference is that the 5D only takes EF lenses, and not EF-S lenses. The 40D takes both. This has both advantages and disadvantages.
There is suppose to be a new 5D coming out soon - a 15.3 MP. But probably wait a while and a new ?0D will come out - a 45D or a 50D? Maybe 12.8 MP?
See
http://forums.dpreview.com/forums/re...5&changemode=1