Loose earths are the most common cause of random power loss... Are you 100% the main efi relay / relays are losing power? or are you assuming because of a loss of spark?
Relays can die also. But you check you have power on the high amp input as well as the wire which trips it and for a solid earth. If so then replace the relay.
But start with checking your earth wires first.