Middle English eilen, ailen, "trouble, afflict, harm," from Old English eglan "to trouble, plague, afflict," from Proto-Germanic *azljaz (source also of Old English egle "hideous, loathsome, troublesome, painful;" Gothic agls "shameful, disgraceful," agliþa "distress, affliction, hardship," us-agljan "to oppress, afflict"), from PIE *agh-lo-, suffixed form of root *agh- (1) "to be depressed, be afraid." Related: Ailed; ailing; ails.
From late Old English also of mental states and moods. Phrase what ails you? "what is wrong with you? why do you behave that way?" is by c. 1300 (what eileth the?)
It is remarkable, that this word is never used but with some indefinite term, or the word no thing; as What ails him? ... Thus we never say, a fever ails him. [Johnson]
<a href="https://www.etymonline.com/word/ailing">Etymology of ailing by etymonline</a>
Harper, D. (n.d.). Etymology of ailing. Online Etymology Dictionary. Retrieved $(datetime), from https://www.etymonline.com/word/ailing