Why is RSA preferred over Diffie-Hellman if they're both used to establish shared key? I've read that the RSA algorithm is preferred over Diffie-Hellman key exchange as it makes key management easier. In the context of online banking, before the RSA algorithm they would have to maintain a different shared key with every single one of their customers, instead of just having one public key and a private key.

But then I've also read that RSA is primarily used for exchanging a shared key for use in symmetric ciphers like AES. So surely no matter if the bank were to use DH or RSA they would still establish a shared key and key management would be just as much a problem as it was before?
RSA is rarely appropriate instead of DH for key exchange. It's mostly only appropriate if backwards-compatibility is required, or if keys need to be sent from one party to the other instead of generated for each session (eg for encrypting e-mail). 

RSA is much, much harder to use securely. RSA requires padding of the messages, which is quite easy to screw up in ways that catastrophically break the security of the system. RSA is far more expensive to use in an ephemeral mode, and thus typically cannot provide forward secrecy. RSA keys are substantially larger than ECDH (Elliptic Curve Diffie-Hellman) keys. RSA key generation is much more complex (and harder to get right) than (some) ECDH key generation: RSA needs to generate large prime numbers &amp; ensure that they are safe, while X25519 or X448 ECDH systems can use any random number of the appropriate length. 

Where possible use ECDHE (Elliptic Curve Diffie-Hellman, Ephemeral). If you can't do that, use DHE. If you can't do that, use ECDH. If you can't do that, use DH. If you can't do that, THEN use RSA. 

RSA can also be used as part of a signature scheme, but that's not relevant to this question since it's not comparable to DH which only does key exchange. TLS 1.3 uses RSA only for signing the DHE or ECDHE key exchange, and also supports ECDSA for signing.

NaCL, Libsodium, Libhydrogen, TLS 1.3, monocypher, and probably a few other libraries and cryptographic standards have dropped the use of RSA for key exchange.