A key pair in AWS is a set of security credentials that consists of a public key and a private key. Its primary purpose is to provide secure access to EC2 instances. The public key is associated with an EC2 instance during its creation, allowing secure authentication, whereas the private key is kept private and is used to securely connect to the instance.