In recent years, inertial sensors based on Micro-Electro-Mechanical Systems (MEMS) have become increasingly popular. They have been widely used in various fields due to their low cost, small size, and low power consumption. It seems that MEMS inertial sensors may eventually fully occupy the middle to lower end inertial navigation application market that traditional inertial sensors previously occupied. To realize the full potential of MEMS inertial sensors, one of the critical issues is their temperature drift. This paper first proposed a recursive model for real-time compensation. Then three algorithms were proposed, including a two-layer deep gated recurrent unit recurrent neural network (GRU-RNN, short GRU), deep GRU based on monarch butterfly algorithm (MBA), and deep GRU based on optimized monarch butterfly algorithm (OMBA). Each of these three algorithms is combined with the real-time compensation model to compensate for the temperature drift of a MEMS accelerometer. The experimental results proved the correctness of these three methods, and the MEMS accelerometer’s temperature drift is compensated effectively. The results indicate that the deep GRU + OMBA shows the best performance for the temperature drift compensation combined with the real-time compensation model. After deep GRU + OMBA method compensation, the angle random walk, the bias instability, the rate random walk, and rate ramp of the MEMS accelerometer were improved from <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$4.97e^{-4} \, mg\,\,\cdot s^{\frac {1}{2}}$ </tex-math></inline-formula> , <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$4.90e^{-4} \, mg$ </tex-math></inline-formula> , <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$5.57e^{-5} \, mg/ s^{\frac {1}{2}}$ </tex-math></inline-formula> , <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$1.82e^{-6} \, mg\,\,/ s$ </tex-math></inline-formula> to <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$3.90e^{-5} \, mg\,\,\cdot s^{\frac {1}{2}}$ </tex-math></inline-formula> , <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$1.07e^{-5} \, mg$ </tex-math></inline-formula> , <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$1.12e^{-6} \, mg/ s^{\frac {1}{2}}$ </tex-math></inline-formula> , <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$3.59e^{-8} \, mg\,\,/ s$ </tex-math></inline-formula> , respectively. Their percentage of improvement reaches 96.50% on average.