When Saul became jealous and suspicious of David, David sought refuge with Achish, the Philistine. the King of Gath, the city from which Goliath had come. According to one version of the event, David was uncertain of his reception by his former enemy and pretended to be mad:
1 Samuel 21
10. And David arose and fled that day for fear of Saul, and went to Achish the king of Gath.
11. And the servants of Achish said unto him, Is not this David the king of the land? did they not sing one to another of him in dances, saying, Saul hath slain his thousands, and David his ten thousands?
12. And David laid up these words in his heart, and was sore afraid of Achish the king of Gath.
13. And he changed his behaviour before them, and feigned himself mad in their hands, and scrabbled on the doors of the gate, and let his spittle fall down upon his beard.
14. Then said Achish unto his servants, Lo, ye see the man is mad: wherefore then have ye brought him to me?
15. Have I need of mad men, that ye have brought this fellow to play the mad man in my presence? Shall this fellow come into my house?
1 Samuel 22
1. David therefore departed thence, and escaped to the cave Adullam. ...
This passage provides evidence that insanity occurred in ancient Israel and was well recognized by distinctive behavior. Furthermore, that it would be faked to achieve personal safety suggests that the mentally disturbed were generally seen as harmless and inoffensive to authority. It also shows a wandering madmen were turned away as a burden and a nuisance.