In Middle English, pentis meant primarily "a shed or roof attached to and sloping from a wall or building." Early evidence of the word includes an anonymous metrical sermon from around 1325: "Thar was na herberie / To Josep and his spouse Marie, / Bot a pendize that was wawles, / As oft in borwis tounes es." (There was no shelter for Joseph and his wife Mary, except a lean-to that was wall-less, as is frequent in borough towns.) Pentis is derived, through Middle French and Medieval Latin, from Latin appendix, meaning "appendage" or "supplement." (A direct borrowing from Latin gives English appendix in its various senses.) Thus, a pentis was a smaller building or structure attached to a larger one.
It was widely—though mistakenly—believed that pentis was related to Middle French pente, meaning "slope," and this belief was very likely encouraged by the fact that many such structures did in reality have sloping roofs. The beginning of the word thus being supposedly accounted for, its second syllable was then altered by folk etymology to -house (it helped that stress was on the first syllable of the word).
A subsidiary structure on the roof of a building to cover a stairway, a water tank, air-conditioning equipment, and the like is still called a penthouse, as is a luxurious and expensive top-floor apartment that commands a panoramic view—a common sense of the word today that was developed in the late-19th century.