It seems that there are a variety of theories.
Theory 1: The Hindu-arabic scholar Abu Ja’far Muhammad ibn Musa Al-Khwarizmi is considered the founder of Algebra. His Book Hisab al-jabr w’al-muqabala (Literally in english: Mathematics of reunion and opposition) is considered the first book on Algebra. In fact thye word Al-Gebra is a distortion of a part of the name of his book: “Al-jabr”.
When the Italians adopted the science of Algebra first around the early Thirteenth century, they also adopted this word. later it was adopted by the english as Aljeber. this word was mixed up with the Spanish understanding of the word Al-Jabr to mean “Bone Setting”. So, at the end of it, the mathematics stream became a homonym to the orthopaedics, and the letter X as a symbol of this science, came to be adopted as the universal symbol for the unknown.
Theory 2: Much of algebra developed when feathers dipped in ink were the most common writing tools. Ball-point pens, and even pencils, were not yet created. The two easiest letters to write were x and y. Mathematicians needed variables they could write quickly without mixing them up. As a result, x and y are still the two most commonly used variables in algebra. Convenience produced the tradition.
Theory 3: It is derived from the Cartesian coordinate system which denotes the three directions of Cartesian space as X,Y and Z. Simple algebraic equation that use X are one dimensional and are plotted along the X axis. That is also why you see x, y and z used in algebraic equations.