Meaning:
Lit. “to have it uneven (not on one level) under the roof” which translates almost exactly into “a bit lacking upstairs”. You use the expression to informally say that someone is mentally unstable or simply not very bright. At the same time, using it makes the statement a bit gentler and friendlier than saying something like “idiota”, “wariat” or outright “popierdolony”.
Poles often use this metaphor to describe a person that is a bit crazy but harmless.