In the pursuit of enhancing harmonic detection precision within microgrids, this paper introduces a pioneering algorithm, VMD-DCHHO-HD, which amalgamates Variational Mode Decomposition (VMD) with an advanced Harris Hawk Optimization algorithm characterized by dynamic opposition-based learning and Cauchy mutation (DCHHO). This study establishes a fitness function based on Shannon entropy, thereby minimizing the Local Minimum Entropy (LME) as the optimization objective for DCHHO. Building upon this, the VMD crucial parameters are efficiently identified using the enhanced HHO algorithm (DCHHO), enabling precise decomposition of complex voltage signals. The proposed method effectively addresses issues commonly encountered in traditional Empirical Mode Decomposition (EMD) during harmonic analysis, such as mode mixing, endpoint effects, and significant errors. Notably, it adeptly captures harmonic components spanning diverse frequencies, offering a nuanced solution to common pitfalls in traditional methodologies. In simulation experiments, VMD-DCHHO-HD showcases remarkable proficiency in extracting microgrid voltage signals, excelling at discerning high-order, low-amplitude harmonic components amid noise. The algorithm's superior precision and heightened reliability, as affirmed by comparative analyses against existing methods, position it as an advanced tool for precise and robust harmonic analysis in microgrid systems.