Loss of fluid pressure internally from a clogged filter, damaged pump, dirt or metal pieces (from other worn parts) making valves stick in the valve body. Slight chance it's electrical (solenoid, wire, ecu) but if the gears won't engage at all it sounds mechanical. Check all the external wiring connections and harnesses for physical damage or disconnected plugs, then test the range switch and solenoids with a DVOM.
The "not shifting into higher gears" thing makes me think dirt or something is making your valve body have fits.
Try changing the fluid and replacing or backflushing the filter screen with brake cleaner. My honda accord was doing the same thing and I changed the fluid 4 times in a row and it became drivable (although it still doesn't like to shift into OD and hesitates for a few seconds). I've been driving it for about a year like that and it hasn't died yet.