First just note the E40D was a disappointment over the C6 in regard to reliability. Its future grand kid the 4R75W is still dying too early and disappointing folks like me! So many, likely most, of the members on this site have taken issue with their E40D. It did however give these trucks the ability to go faster on the HWY and lower the RPM which is a win-win of sorts. (I am doing 2,700RPM at 63MPH with a C6, since I mainly use this truck for towing and Home Depot runs that works for me. However, I wish I had a 4th gear to drop the RPM's to say 2,100 at 65mph.) So, know rebuilding the tranny is big bucks but it will bring back tens of thousands of miles of no tranny issues. (Not to mention a new diesel Ford F250 Super Crew is $65,000.)
The part that suggests start with the tranny is you say you lose torque (Now that can be debated what everyone defines torque as when driving.) but keep RPM's. You mention you are told you have large chunks of something in the pan and burnt tranny fluid. That your truck is batting 75% working, 25% not working. The tranny is hunting/shifting erratically at times. All sound like tranny issues, not an engine losing power/torque. If it was engine torque the tranny would downshift, but not shift erratically in my opinion. (Just keep downshifting.) The chunks could be clutch material/clutch band material or metal from something gone wrong. But common when something is wrong is the clutches slip, the fluid burns, and you lose power/torque to the axle, but your engine torque is still the same. (The tranny thus is not delivering the torque/power from the engine as torque/power to the driveshaft and axle, it is wasting the engine torque/power from letting the clutches slip and burn.) In this case the vehicle slows down but your RPM's stay up or increase. In this scenario it is not an engine issue rather a tranny issue. Just know in this case you are likely running up your rebuild bill as you can now start to damage the metal parts (Heat warp, cracks, contamination, and bluing.) due to the slipping and polluting of the tranny fluid.
Perhaps you can quickly determine if your tranny, torque converter, or engine seem to be the actual culprit. Some food for thought on how to determine.
1) Tranny - You may notice the RPM's do not decrease or possibly increase upon noticing less torque/power to the wheels. A very common cause is the tranny clutches are slipping. (Truck goes slower, but engine maintains or increases RPM.) This would also confuse the E40D as RPM's are high, wheel speed is low, and gas pedal is perhaps done far or all the way. Telling the tranny to change gears or hunting trying to get within the parameters it is set for. When you went to 4wd low, the clutches had to work far less to move the vehicle as it was now geared down and reducing the amount of work the tranny needed to do.
2) Torque converter - As I recall one advantage of a E40D over a C6 is the lock up torque converter. So perhaps what you are experiencing is a lack of lock up. (But does not explain why you could not get up a hill at slower speeds.) So at HWY speeds your noticing less power or a downshift. This still is a tranny related issue. If you have chunks of material and burnt fluid you still want to do both. If your torque converter had bitten the dust it would also bend or perhaps break off fins and perhaps that is part of the "Chunks" in the tranny pan. Giving you less torque/power to the axle at all times.
3) Engine - My experience when a IDI is ailing you feel a lot of uneven or dramatic power/torque changes. (Truck making clear changes via surging from power and accelleration. To slowing and lower RPM's.) It seems as if these engines are either charging forward, or they are slowing the vehicle. (Maybe not slowing as much with a E40D, perhaps you go into a neutral state like many overdrive vehicles do when releasing the gas pedal, I have not been in a IDI with a E40D.) When having a fuel issue if you keep your foot in one position the truck cuts some/all power, then comes back, then cuts and comes back. Then often just cuts out because of the fuel starvation problem. Clog, air in the lines, or failure of the lines, IP, the tank is empty (Many fuel level gauges no longer work on these old beasts!
or lift pump. My point is you should be able to tell because of a drop off in engine power/torque is immediate and resulting in changing RPM's and a surge to slow down or a surge to speed up. VS a tranny or torque converter that would be more Suttle/softer change of power/torque. (More on loosing, less on surging back to power.)
Two thoughts why I still think you start with the tranny. 1) You did not explain any of the above engine symptoms. 2) As mentioned earlier check your turbo, it could dramatically change the engine performance if your bearings or something is impeding the turbo from spinning. But doubt it would cripple the engine so much you needed 4wd low to move the truck. Check the fan for side-to-side play. (It will have a little but not much.) Does it spin freely with your finger or do you have to turn with a socket. (It should turn freely.) Do you see any broken fins or a cracked housing?
Then you should know if you should spend say $3,000 (Less if you pull and replace it.) on a tranny or say $1,700 on a rebuilt IP and new injectors. (After you confirm it’s not a fuel supply issue to the IP.) I would hate for you to spend $1,700 then find out that did not fix your truck and now have your truck down waiting to do the $3,000 tranny.
All the best and be sure to follow up with what you did to fix it.