According to the OED, textbook derives from an obsolete sense of text, that is, text-hand:
1730 N. Bailey Dict. Britannicum (folio), Text-Book (in Universities) is a Classick Author written very wide by the Students, to give Room for an Interpretation dictated by the Master, &c. to be inserted in the Interlines.
In other words, a text-book is a book written in a widely space format, i.e. in text-hand:
A fine large hand in writing.
a. orig. One of the larger and more formal hands in which the text of a book was often written, as distinct from the smaller or more cursive hand appropriate to the gloss, etc.
R. Holme Acad. Armory iii. 414/2 These are the form of the Letters..used by the Germans; and are termed the Text Hand Letters.
b. Now usually applied to a school-hand written in lines about half an inch wide.
Text-hand, in other words, refers to the hand (script) use to represent the text— words and sentences in the original form and order, as distinguished from a commentary, marginal or other, or from annotations. Hence, in later use, the body of any treatise, the authoritative or formal part as distinguished from notes, appendices, introduction, and other explanatory or supplementary matter. Its size and spacing allows commentary to be written in between the lines.
The origin of text is Latin via French, and as the commenters note, used originally of Scripture and the like.
From the same origin comes text-writer, i.e. a professional writer of text-hand, before the introduction of printing; later, an engrosser of legal documents, from which derives the modern meaning of the author of a legal textbook.