The inscription of Psalm 34 reads like this:

Concerning David, when he pretended to be insane in the presence of Abimelech, who drove him out, and he departed.

For those who don’t know the story, or if it’s a bit rusty like myself that I didn’t catch it, this is a bit of a surprise.  When we go back to reach the story in 1 Sam 21, we see

  1.  It was “Ahimelech” and not necessarily “Abimelech” mentioned
  2. It was actually “King Achish of Gath” where we see that David pretended to be insane (1 Sam 21:10-11)

The first question isn’t really an issue.  Abhimelek and Ahimelek were interchangeable. But the second issue requires a little more thought.  There are several responses

1)  It’s important to note first of all that these superscriptions above the psalms were not ever considered inspired, but rather editorial clarifications inserted into the psalms at a later time.  But even then, why was this psalm deemed to be linked to 1 Sam 21?  Here are some possibilities:

2) “Abimelech” was a general royal title such as “President” or “Prime Minister.”  Then he would be referring to Achish as the “royal leader” to whom David feigned insanity.  This is possible as “Abimelech” means literally Father-King/Ruler and was common among Philistine dynastic rulers (see Genesis 20, 21:22-34 and 26).  If this is the case, then Achish would be the Abimelech/Father king of the Philistines of Gath.