Replacing Bath Fan Switch with Timer Switch
First, let's label these cables:
Please confirm that this is correct:

Incoming power
Travelers to 2nd 3-way switch
Always on - receptacles? lights in other rooms?
Either incoming power to 3-way switched lights or switched hot to 3-way switched lights
Fan

Note that if this diagram is correct, the power and neutral for the 3-way switched recessed lights is separate from everything else. That is perfectly fine, but you need to keep it separate.
Replacing the fan switch
&quot;Top&quot;/&quot;Bottom&quot;/&quot;Left&quot;/&quot;Right&quot; are to be ignored when it comes to old switch vs. new switch because each manufacturer (and even each model within a manufacturer) does things differently. In your particular case, the new timer/switch has colored wires so that makes it easy:

Black wire on top of old switch is hot. This connects to hot/black on the new switch.
Black wire on bottom of old switch is switched hot. This wire, black from cable 5, connects to load/red on the new switch.
White wire on new switch should be connected together with the 3 white wires that you show near cable 5 - connected to 1, 3 and 5.
Ground/green should be connected together with all other grounds. Typically you will have a bare ground wire coming out of each cable if these are typical NM (aka Romex) cables. If you do not see any bare wires and it is a metal box and the wires are coming through metal conduit (which may be hard to tell unless you have some other part of the wall open) then the ground is the metal conduit. If that's the case, you can connect the timer/switch ground/green wire to the metal box using an appropriate screw.