The W140 S 320 and the W124 E 320 do have very similar engines. The hp on the W140 is slightly higher due to a higher free flow exhaust system that cannot fit under the W124. But, that where its similarities end!
Having extensively driven both series back to back I can say that the S-class is definitely a much superior automobile. NOT the W124 is not great, IT IS!!! It is just the W140 is on a league of its own. Its size, its solid construction, its weight, its refinement, everything about it is out of this world. Seen separately is diffucult to understand this, but try to get a W140 and a W124 side by side and compare them, you will understand.
Just be careful: for some reason W140s do tend to deteriorate faster than W124s under missly maintenance. For some reason, W124s do tend to be more forgiving when overlooked. In a nutshell: if you are going to buy a W140, be sure it is in prime condition!
I would consider a 97/98/99 for a W140. 95s and early 96s were still sorting out original manufacturing problems. Pre-facelifted 91-94s are nice, although they tend to really give you headaches in terms of maintenance.
If you would like to know more about the differences for W140 pre and post facelift models, check out this thread and read its first two pages:
http://www.peachparts.com/shopforum/showthread.php?t=19772