The preparation of bio-oil through biomass pyrolysis is promoted by different demineralization processes to remove alkali and alkaline earth metal elements (AAEMs). In this study, the hydrothermal pretreatment demineralization was optimized by the response surface method. The pretreatment temperature, time and pH were the response elements, and the total dissolution rates of potassium, calcium and magnesium were the response values. The interactions of response factors for AAEMs removal were analyzed. The interaction between temperature and time was significant. The optimal AAEMs removal process was obtained with a reaction temperature of 172.98 °C, time of 59.77 min, and pH of 3.01. The optimal dissolution rate of AAEMs was 47.59%. The thermal stability of eucalyptus with and without pretreatment was analyzed by TGA. The hydrothermal pretreatment samples exhibit higher thermostability. The composition and distribution of pyrolysis products of different samples were analyzed by Py-GC/MS. The results showed that the content of sugars and high-quality bio-oil (C6, C7, C8 and C9) were 60.74% and 80.99%, respectively, by hydrothermal pretreatment. These results show that the removal of AAEMs through hydrothermal pretreatment not only improves the yield of bio-oil, but also improves the quality of bio-oil and promotes an upgrade in the quality of bio-oil.