One of the most important challenges for heterogeneous wireless sensor networks (HWSNs) is adequate network coverage and connectivity. Aiming at this problem, this paper proposes an improved wild horse optimizer algorithm (IWHO). Firstly, the population’s variety is increased by using the SPM chaotic mapping at initialization; secondly, the WHO and Golden Sine Algorithm (Golden-SA) are hybridized to improve the WHO’s accuracy and arrive at faster convergence; Thirdly, the IWHO can escape from a local optimum and broaden the search space by using opposition-based learning and the Cauchy variation strategy. The results indicate that the IWHO has the best capacity for optimization by contrasting the simulation tests with seven algorithms on 23 test functions. Finally, three sets of coverage optimization experiments in different simulated environments are designed to test the effectiveness of this algorithm. The validation results demonstrate that the IWHO can achieve better and more effective sensor connectivity and coverage ratio compared to that of several algorithms. After optimization, the HWSN’s coverage and connectivity ratio attained 98.51% and 20.04%, and after adding obstacles, 97.79% and 17.44%, respectively.