The IRF540 is an n-channel device. This requires the gate to be brought higher than the source to turn on. What’s happening instead is that the FET is following the gate voltage, minus the threshold voltage. So if the n-FET gate is at 5V, and threshold is 2V, then it won’t conduct if the drain is higher than (5V-2V), or 3V. So it swings to that and pinches off.
Instead, use a p-FET, which switches on when the gate is lower than the source. Gate at GND, FET is fully on, gate at 5V, FET is fully off. The AO3401A is a 4A device that would work fine for this, but any ‘logic level’ p-FET rated for the current you need would work.
If you decide you need a relay (maybe you want dry contacts?) consider that you’ll still probably need a FET to drive its coil. This is more easily done if you drive the low side with an n-FET, but a p-FET on the high side works too. Either way, don’t forget the catch diode: without it, the coil flyback will kill your FET.