Madman Theory
en.wikipedia.orgIt's fairly rational when you think about it. If you act irrational, it's harder for the leaders of other countries to predict your responses to their actions. You may, for example, respond disproportionately to a perceived attack. This possibility engenders caution and hesitancy in foreign leaders.
Of course, this is a double-edged sword. Enemies may be more cautious, but so too may allies. Alliance credibility is awfully weak when the sanity of your leader is in question.