Removing attic fan thermostat - how to terminate 3-wire
Everything on the left side of the box is wrong, this isn't a simple matter of what to connect together. I don't know if it was the roofers that messed it up of if it was wrong to start with. However all conductors must be inside sheathing [or conduit or a box] at all times, meaning that the cable sheathing must come slightly inside the box and the cable clamped at the entrance or within 6 inches of the entrance. 
Second there aren't enough conductors on the left to do anything.
Keep them all disconnected and capped separately.

To solve the lamp issue start with the lamp fixture and switch, test the wires for voltage, if it has power change the bulb if no power trace it back until you find power. This requires a meter of course, no practical way around that.