Since there was no other answer yet but "leave!":
Option A:
Be friendly, supportive, but not afraid to even oppose him in a friendly way. Do show him problems you see, but do not try to "win" any discussion. Also make sure he never looses face. Try to find out where he will appreciate kind words and support.
In a way: Be the calm and friendly "adult" of the two of you.
You will not be able to make a great boss out of a bad one, but you might find a better way to live with each other.
Option B:
Ask your boss's boss if you can be placed in some other place of the company's hierarchy. You do not need to stress (or even mention) the short-commings of your current boss. Simply use "I-messages" and say something like "I feel uncomfortable working with X. I think he is a very capable person, but I am not very compatible. I could be more productive for the company working for a different superior."
Option C:
Try to get him out of the company. This is a whole new topic/question in it's own (or even several), so I will not elaborate here. But it is an option that might be viable in some circumstances.