Herodes:
Jobi-Wan: I have powered the relays with a 5V separate Arduino source. But that is not the problem for now: now, my problem is to be able to transmit to the 595 what the 165 command. I can do it with LEDs and resistors, no problem.
If you supply power from one Arduino and signal from another, then those two Arduinos should have their grounds connected together.
If you can do it with LEDs, but not with your relays, then your relay board is not wired up correctly.
How did you test and confirm that your outputs are working?
Can you explain in detail how your program works? Especially writeRegisters() and setRegisterPin()