Each of the following reference material has a specific purpose, but the one that contains the etymology or history of a word is the dictionary, which lists words and their definitions, meanings, pronunciation or translation.
Thesaurus is a reference book containing groups of words that are similar.
Glossary is the vocabulary of a text.
Encyclopedia is a book or many books containing articles in alphabetical order.