D&D is designed for combats with a handful on each side. So how do you scale that up to larger numbers? Here are various suggestions, from the DMG, @slyflourish, @louanders, #TalesOfTheValiant, and the #BECMI Companion set
The Companion Set of the BECMI D&D boxed sets contained rules for Mass Combat, called The War Machine, which are still the best set of mass combat rules to fit into D&D which I’ve come across.