Looking up their definitions:
There seems to be no logic behind combining 客 and 气 to give 客气.
Question: How does 客 and 气 combine to give 客气?
I think the logic is like 口气，语气.
口气 is tone in English. 气 is air. 口气 is air from your mouth. Figuratively, it becomes your tone with which you speak.
So, my thought for 客气 would be you speak in a guest's tone, which implies you are being polite.
"客气" can be traced back to a story in The Spring and Autumn period(I did search this term....what an awkward name). This term was to describe actions that not from the heart, just for being polite. Now it becomes a neutral term - "you're welcome".
'polite' comes from the Latin politus "refined, elegant, accomplished," literally "polished," past participle of polire (polish, not Polish), but that doesn't mean someone who is polite is shiny!
Maybe it originated from 'in the spirit or air of a guest', the assumption being, a guest is very well behaved. (Back then the Chinese never had English guests perhaps, or they might not have used this metaphor)
气: (19) 指精神状态,情绪 [morale;spirit] or
气： (25) 中医学术语。指脉气和营卫 [energy of life;vital energy]
气 Has many uses, just as "air" does in English:
an air of insouciance
give someone the air
the radio station is on the air
putting on airs
take a sweater or jacket out for an airing