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.