Oh, understood about the loose connection, but so many wires had melted. Usually the loose one will melt and the bus bar has enough mass to dissipate the heat, not melting more wiring, that is unless this was really hot.
Looking back to the original OP question, I would almost suspect the blue wire would be from the converter, if in fact you originally had a 40 amp breaker in the box. The breaker appears to have been removed and the wires to it were spliced together and taped.