Key pairs are used to log in to the EC2 instances. They act like access credentials to EC2 instances. They use public-private keys to encrypt and decrypt the login credentials. While creating EC2 instances, we need to associate key pairs so that the user can use them to log in using SSH.
Store key pairs at a secure location because they act as a password for users to connect to your EC2 instance. If the key pair is lost, we cannot recover it. So, we need to generate another key pair and relaunch the EC2 instance with the new key pair.