Agriculture, as a sector that is highly influenced by weather conditions, faces challenges due to increasingly unpredictable changes in weather patterns. The aim of this research is to create an optimal rainfall prediction model to help farmers create irrigation schedules, use fertilizer, and planting schedules, and protect plants from extreme weather events. The method used in this research to obtain the best rain prediction model is to use the random forest algorithm and the grid search cross-validation algorithm. Random Forest, known for its robustness and accuracy, emerged as a suitable algorithm for predicting rain. utilizing a substantial dataset from the West Nusa Tenggara Meteorology, Climatology, and Geophysics Agency covering the period 2000 to 2023. The data is then processed first to ensure its readiness for use. This process involves removing outlier data points, empty data entries, and unused features. After the preprocessing stage, the data underwent training using the Random Forest algorithm, resulting in an R-squared value of 0.1334. To obtain the optimal model, Grid Search Cross Validation is used. The results of this research obtained the best rain prediction model with an R-squared value of 0.0268. This model will be used to predict rain in the agricultural sector. This research concludes that we can get the best rain prediction model by combining Random Forest and Gird Search Cross-Validation. For further research, we can compare other rain prediction methods, add features, and combine datasets from a wider area.