This study proposes a new method for correcting the Shuttle Radar Topography Mission (SRTM) digital elevation model (DEM), as current methods, such as the polynomial regression (PR) method, are limited in their ability to fully capture complex nonlinear relationships between elevation errors and their influencing factors. The proposed method combines the benefits of particle swarm optimization (PSO) and random forest (RF) algorithms. First, elevation control photons (ECPs) are extracted from strong beams of the Advanced Topographic Laser Altimeter System (ATLAS) on the Ice, Cloud, and land Elevation Satellite-2 (ICESat-2), and the elevation errors of the SRTM DEM, terrain factors, and landcover classes for each ECP are then calculated. Next, a SRTM DEM correction model based on the RF is designed, and PSO is utilized to determine hyper-parameters of the RF. Finally, the corrected SRTM DEM for the San Joaquin Valley and the Sierra Nevada is produced as an example. The proposed PSO-RF correction method is validated using high-precision airborne light detection and ranging (LiDAR) data, and the results show that it significantly improves the quality of the SRTM DEM. Specifically, the mean absolute error (MAE) and root mean square error (RMSE) are 9.24% and 13.3% lower than those of the existing PR method in the study area, respectively.