I think an example would help here. Lets say you are storing the name of all employee in your organization.
e.g.
Alan, Matt, Mark, Sam, Sunil
If you store them normally without hashing, searching for a single employee would mean looking at all 5 names (you could use some searching technique, but still need to look at 5 elements)
Now lets use a very simple hash called "First Letter"
A - Alan
M - Matt, Mark
S - Sam, Sunil
Searching for employee starting with 'S' would mean find the hash bucket and then looking only within that hash bucket which improves performance.
A hash function should
a) Distribute the data-set into a smaller set of hash buckets
-- so a hash function that distributes 100 elements in 1 bucket or in 100 buckets is bad. If it distributes it in 10 buckets is good
b) Each 'bucket' should be uniform in size
-- so in hash function above if one bucket contains 91 elements and other buckets contain 1 element each it is bad. If each bucket contains 10 elements it is good
Note: Hash called "First Letter" is not really very good, since we would have more name starting with some letters like 'R' or 'S' v/s names with say 'X' 'Y' or 'Z'