There are tons of threads here on the board with E9x comparisons. In reality, these two cars fill significantly different niches...enough so that the fact they are RWD V8 isn't enough to assume they should fill similar roles in some equal fashion. It's funny that people "complain" about torque of the S65, enough so that BMW Car magazine compared the two cars years ago and broke out measured in-gear acceleration in 10mph increments for every gear all the way to 150mph. They surprisingly found the E90 M3 beat the E39 M5 in speed increments they didn't believe (stuff like 5th gear 60-80 where both engines are out of their juicy spot) since the E90 "felt" slower behind the wheel. Of course overall, the E90 M3 is the faster car by a good amount (i.e. 0-60 4.1 sec vs M5 4.8, 0-100mph in 9.8 sec vs M5 11.3 sec -- times for 6MT E90, both data from C&D testing), but "the feel" everyone talks about is somewhat of a misleading butt-dyno effect.
The E9x M3 is geared such that in 2nd gear, for example, it is running about 1400 rpms higher engine speed for the same road speed compared to the M5 (no surprise both cars are properly geared based on their engine's torque curve). Hence one reason butt dyno impressions are tainted is that people look at engine speed, say 2500rpms in 2nd gear, and compare "feel" when applying throttle as opposed to matching road speed in 2nd gear for their comparison (i.e. 2500 in 2nd in M5 ~= 3900 in 2nd in M3).
The net of all this imo is that the E90 M3 is a *much* different driving car than the M5 and likely *not* suitable for daily driver duties many subject an M5 to doing. It's louder, much firmer riding (still supple though), much more connected experience (i.e. the 12.5:1 ratio, hydraulic assisted, rack and pinon steering is incredible), and the visceral feel to the S65 is sublime, especially from 6500-8400 rpms. It's a much more of a purists/enthusiasts sports sedan to the nth degree, one of which will never be seen again (normally aspirated 8000+ revving V8). If you have a lot of HPDE/autocross/track time trials/racing in your background and want a beast that will tingle your spine, the E90 M3 is it.
The M5 on the other hand is more of a boulevard cruiser that "isn't bad" on track once you do a good bit of suspension mods. The M5 is obviously aged in many ways not the least of which is the E39 chassis was in design phase well over 20 years ago now. I've always thought of my M5 as the epitome of my first BMW, the 1972 Bavaria (E3), which shared much in common with the E39 layout right down to the recirculating ball steering -- the M5 feels like taking the Bavaria through every evolution possible in every category.
It gets better gas mileage than the E9x M3 too, lol, which is actually a good bit better than the last iteration of my Bavaria too (i.e. with a fully built M30 six, cam, triple sidedraft 45mm Webers, etc, it loved to use gas
...just random thoughts from about to start year 14 with the M5 and year 5 with the M3.