RSA is a public-key cryptosystem that uses public and private key pairs to encrypt and decrypt messages. The public key is used to encrypt messages and can be shared widely, while the private key is used to decrypt messages and must be kept secret. RSA works because it is computationally infeasible to factor the product of two large prime numbers, even though it is easy to multiply them together.