A quire was originally a small medieval book or pamphlet, especially one constructed of a set of four sheets of paper folded in two, forming eight leaves. The quire grew in time, and it came to be a collection of 24 (sometimes 25) folded or unfolded sheets, which makes a ream of 480 sheets of paper 20 quires, and a quire one twentieth of a ream. (Ream in this sense is from Arabic rizma, which literally means "bundle"; the verb ream with the slangy sense of "reprimand" may come from a Middle English word meaning "to open up," but that's an educated guess so don't ream us out if it turns out not to be true.) Quire is ultimately from Latin quaterni, meaning "set of four," and entered Middle English via Anglo-French.
For those who might be contemplating the similar pronunciation of quire and the "singing" choir, quire is actually an archaic variant of the word. Choir is also derived from Anglo-French: it is from queor, a French formation derived from Medieval Latin chorus, referring to a company of singers in church or the area in which they sing. Quire was often used in English as a variant of choir up to the close of the 17th century.