Is it better to replace an old hard drive with a new one or to upgrade RAM?

It depends on the individual situation. If the problem you are experiencing is slow performance or software crashing due to not enough RAM, then upgrading the RAM would be the better option. If the issue is due to a worn out or failing hard drive then replacing the hard drive would be the better option.