This paper proposes an Improved Lemur Optimization algorithm (ILO), which combines the advantages of the Spider Monkey Optimization algorithm, Simulated Annealing algorithm, and Lemur Optimization algorithm. Through the use of an adaptive nonlinear decrement model, adaptive learning factors, and updated jump rates, the algorithm enhances its global exploration and local exploitation capabilities. A Gaussian function model is used to simulate the mountain environment, and a mathematical model for UAV flight is established based on constraints and objective functions. The fitness function is employed to determine the minimum cost for avoiding obstacles in a designated airspace, and cubic spline interpolation is used to smooth the flight path. The Improved Lemur Optimization algorithm was tested using the CEC2017 benchmark set, assessing its search capability, convergence speed, and accuracy. The simulation results show that ILO generates high-quality, smooth paths with fewer iterations, overcoming the issues of premature convergence and insufficient local search ability in traditional genetic algorithms. It adapts to complex terrain, providing an efficient and reliable solution.