Why did David compose this Mizmor?
Malbim: It explains how Hashem's Hashgachah clings to Tzadikim to guard them and save them from all mishaps, and especially how He is close to hear Tefilah. It teaches Yir'as Hashem and what it is. It was Hashgachah Pratis that Avimelech expelled David, and did not heed his servants to kill him.
What is the meaning of "b'Shanoso Es Tamo"?
Shocher Tov: David asked Hashem to put lunacy upon him. 1
Rashi: This is like it says "va'Ysav Al Dalsos ha'Sha'ar 2 va'Yored Riro El Zekano" (Shmuel I, 21:14). He changed his speech and reasoning in front of them and acted like a lunatic.
Shochar Tov: Earlier, David had said "You did all Your deeds with Chachmah" (104:24) - except for all lunacy. Hashem said, do you complain about lunacy? You will need it! Refer also to Shmuel I, 24:3:2:1 and the notes there.
Radak (2, from Shochar Tov): He wrote 'Achish Melech Gas owes me 1,000,000 gold coins.'
Why did he act like a lunatic?
Radak #1: It was so they would think that he is not David.
Radak #2: When they see him acting crazy, they will not be concerned for his strength, and not kill him.
In Shmuel I, 21:11 the king is called Achish!
Rashi: All kings of Pelishtim are called Avimelech, and all kings of Egypt are called Pharaoh. Even though his name was Achish, he is called Avimelech. Radak - we find that Melech Pelishtim is called Avimelech in the days of Avraham and Yitzchak.
Rashi citing Shocher Tov: He was a Tzadik like Avimelech. He did not want to kill David; "his men said, this is David, Melech ha'Aretz" (Shmuel I, 21:12)!
Radak: He had two names.
Why is this Mizmor according to the Aleph Beis?