Social networks accelerate information communication in public health emergencies. Some negative information may cause an outbreak of public opinion crisis. Accurately predicting online public opinion trends can help the relevant departments take timely and effective measures to cope with risks. Therefore, this research proposes a prediction model incorporating the swarm intelligence optimization algorithm and the deep learning method. In this model, we improve the Harris Hawks Optimization (HHO) algorithm by introducing the Cauchy distribution function, the stochastic contraction exponential function, and the adaptive inertia weight. Then we utilize the improved HHO (IHHO) algorithm to optimize the hyperparameters of the deep learning method LSTM, including the learning rate and the number of neurons in the hidden layer. Finally, we construct the IHHO-LSTM model to make predictions in three public health emergencies. The experiments verify that the proposed model outperforms other single and hybrid models. The MAPE values reduce by 78.34%, 54.46%, and 46.42% relative to the average values of the three single models. Compared with the mean values of the two hybrid models, the MAPE values decrease by 47.69%, 18.45%, and 5.78%. The IHHO-LSTM model can be applied to public opinion early warning and reversal identification, providing a reference in public opinion management.