If you know that everyone has a unique social security number (SSN), then you could create an index of everyone's name, ordered by SSN. Then, if you were given someone's SSN, it would be really quick to find their name.
Now assume that you have a manilla folder for each person. The card may have detailed medical records etc. Your database may not keep these cards in order - maybe it just adds new folders to the end of the compactus. But it keeps a sorted "index" so that if you look up an SSN, it can tell you exactly where the relevant folder is kept.
In this example, the SSN is being used as a Primary Key. It's nice if it's unique, but even if it isn't unique, it can still speed things up.