From what I can see, the relay is a 5 pin device, and called the “starter inhibit relay”. There are a bevy of other 5 pin relays plugged into the same relay panel, so maybe it is possible to swap them around. Hard to say. If the relays being swapped are the exact same part number then it is probably ok.
It looks like that relay’s purpose is to prevent the engine from starting in situations where it shouldn’t, like if the automatic transmission is in gear, or if a manual, the clutch pedal hasn’t first been depressed. It’s a safety device in other words. The transmission control module (tcm) is what grounds the relay coil, to activate it. The posts above are correct, the more likely cause of this fails to crank problem is either something wrong with the signal from the tcm, or a problem with the starter motor itself.
My guess, swapping the starter-inhibit relay had no effect at all, just a coincidence that the engine started afterward. More likely either the tcm isn’t recognizing that the transmission is already in P or N (or the clutch is depressed), or that there’s a problem with the starter motor.
If I had this problem: First, I’d remove, clean, then re-tighten the battery terminals. That alone might fix it. If not, next, I’d measure the voltages directly at the starter motor, terminal to case, both the battery and start terminal, during attempted cranking. If both are above 10.5 volts and it won’t crank, the starter motor needs to be replaced. If one or both are below 10.5 volts, find out why.
Edit: On some cars with automatics the brake pedal is involved in the starting process too. If the switch that detects the brake pedal is pushed isn’t working, this can result. Also if there’s an anti-theft system that’s not working.