The math behind RSA is simple, but the attacks against poorly-chosen secret keys and poor implementations are extremely subtle.
RSA should be taught to students as their first asymmetric crypto algorithm, and probably always will be. But nobody should start using it where it was not already in use.
1. Constant time bigint arithmetic, and
2. The padding scheme (which has had MANY issues over the years)
Done correctly is relatively complicated. But a shitty insecure version of RSA is easy to write.
First, that seven lines of code includes a bignum arithmetic library, but the ones shipped with your language are not constant-time and not suitable in any way, shape, or form for use in cryptographic code.
Then it’s a pain in the ass and slow to encrypt large messages so literally nobody uses RSA to do so. They generate a symmetric key and use that to encrypt the message then use RSA to encrypt the symmetric key.
With both of those you’ve managed to get to a minimally useful but still laughably insecure RSA implementation.