Melee and ranged weapons are reasonably balanced in a dungeon delving context. In a high visibility outdoor encounter, though, a melee-focused combatant is utterly helpless against a range-focused combatant of comparable level or CR.
Absent terrain/visibility restrictions, a melee warrior using the dash action will need 20 rounds to close with a longbow wielder stepping backwards while firing. That may be an extreme case, but having to endure even half a dozen rounds of fire, even with partial cover intermittently available, is a sufficient obstacle that, under 5e rules, no one in their right mind would come to an outdoor battle armed primarily with a melee weapon. Both balance considerations and historical practice, though, suggest that it should be entirely plausible for a warrior with a shield and spear to close with an archer.
Outdoor combat may not be the primary focus of D&D, but neither is it a rare enough scenario that it's alright for it to break game balance to this degree.