Public-key cryptography suffers from the risk that the public key might be from someone who isn’t who they say they are.
A digital signature is a hash of the public key encrypted by the private key. The person with the matching public key decrypts the digital signature using the public key, generates their own hash, and compares it to the decrypted hash to verify it came from the intended sender.