Word Origin and History for at the top of one's lungs
"human respiratory organ," c.1300, from Old English lungen (plural), from Proto-Germanic *lungw- (cf. Old Norse lunge, Old Frisian lungen, Middle Dutch longhe, Dutch long, Old High German lungun, German lunge "lung"), literally "the light organ," from PIE *legwh- "not heavy, having little weight; easy, agile, nimble" (cf. Russian lëgkij, Polish lekki "light;" Russian lëgkoje "lung," Greek elaphros "light" in weight; see also lever).
The notion probably is from the fact that, when thrown into a pot of water, lungs of a slaughtered animal float, while the heart, liver, etc., do not. Cf. also Portuguese leve "lung," from Latin levis "light;" Irish scaman "lungs," from scaman "light;" Welsh ysgyfaint "lungs," from ysgafn "light." See also lights, pulmonary. Lung cancer attested from 1882.
Medicine definitions for at the top of one's lungs
Either of the two saclike organs of respiration that occupy the pulmonary cavity of the thorax and in which aeration of the blood takes place. It is common for the right lung, which is divided into three lobes, to be slightly larger than the left, which has two lobes.
Either of two spongy organs in the chest of air-breathing vertebrate animals that serve as the organs of gas exchange. Blood flowing through the lungs picks up oxygen from inhaled air and releases carbon dioxide, which is exhaled. Air enters and leaves the lungs through the bronchial tubes.
Also, at the top of one's voice. With an extremely loud voice. For example, The babies in the nursery all were crying at the top of their lungs. The noun top here refers to the greatest degree of volume (that is, loudest) rather than high pitch, a usage dating from the mid-1500s.