The aim of this study is to select the best model (combination of different lag times) for predicting the standardized precipitation index (SPI) and the standardized precipitation and evapotranspiration index (SPEI) in next time. Monthly precipitation and temperature data from 1960 to 2019 were used. In temperate climates, such as the north of Iran, the correlation coefficient of SPI and SPEI was 0.94, 0.95, and 0.81 at the time scales of 3, 12, and 48 months, respectively. Besides, this correlation coefficient was 0.47, 0.35, and 0.44 in arid and hot climates, such as the southwest of Iran because potential evapotranspiration (PET) depends on temperature more than rainfall. Drought was predicted using the random forest (RF) model and applying 1–12 months lag times for next time. By increasing of time scale, the prediction accuracy of SPI and SPEI will improve. The ability of SPEI is more than SPI for drought prediction, because the overall accuracy (OA) of prediction will increase, and the errors (i.e., overestimate (OE) and underestimate (UE)) will reduce. It is recommended for future studies (1) using wavelet analysis for improving accuracy of predictions and (2) using the Penman–Monteith method if ground-based data are available.