Describes someone as mentally unstable or acting irrationally. Often used in a colloquial, somewhat strong way. The phrase is a set expression meaning 'one's mind is strange'.
あんなことを言うなんて、彼は気が変なんじゃないか。
Saying something like that, he must be crazy.
気が変になりそうだ。
I feel like I'm going insane.
A set phrase combining 気 (mind/spirit) with 変 (strange/abnormal). The exact historical derivation is uncertain, but it follows a common pattern of describing mental states with 気が + adjective.