Encryption is the process of transforming plaintext (readable data) to ciphertext (unreadable data) with the help of a mathematical algorithm and a key. This data can only be decrypted with the help of the correct key (not necessarily the same one used for encrypting it).
There are only two types of encryption, symmetric and asymmetric.
Symmetric encryption is when you use the same key to encrypt and decrypt the data. Let's say we have two computers on opposite sides of the world and computer A wants to send a secret message to computer B. So computer A generates a key and encrypts the payload using that key and sends the message to computer B over the internet. But wait... how will it send the actual key that computer B will need to use to decrypt the message? If computer A sends the key over the internet unencrypted (if we encrypt the key we will have to send another key to decrypt this key and so on...), then the message can be decrypted by anyone which defeats the entire point of encrypting the message in the first place.
To solve this problem, asymmetric encryption was created. Asymmetric encryption uses two different keys, one for encryption and one for decryption. Both of these keys are related to each other mathematically, but one can never be derived from the other. These 2 keys are called public and private keys. As the name suggests, public key is accessible to everyone using which they can encrypt messages. But only the owner of these keys has access to the private key. The private key is used by the owner to decrypt whatever messages were encrypted using the public key.
Let's consider the same case where computer A and computer B want to communicate secretly with each other. Each computer will generate their own pair of public and private keys using RSA, the most widely used asymmetric algorithm in the world, and share their public keys with the other computer. Now computer A has B's public key and computer B has A's public key. Now if computer A wants to send computer B a message, they can simply use B's key to encrypt the message and send it over the internet. Now because only B has access to its private key, which was never shared with anyone, it can decrypt and read whatever message was sent by computer A ensuring that even if the message is intercepted in transit, it remains completely unreadable to anyone but computer B.
Asymmetric encryption solves the key distribution problem by producing a public key that you can share upfront with anyone in the world.
However, encrypting messages using asymmetric keys is a lot more computationally intensive as compared to symmetric keys, especially for larger messages. To overcome this today we usually use a combination of both. We generate symmetric keys, and encrypt it asymmetrically, and share it safely with the other party. And then use these symmetric keys for encryption of the actual messages.
This is exactly what happens every time you open an HTTPS website, asymmetric encryption secures the handshake and symmetric encryption handles the rest.