Any game with both melee and ranged attackers faces a great conundrum. How do melee and ranged attackers fight against each other in any sort of balanced way? Your answer will depend on the game, as designers choose numerous different ways to balance these things.
We'll be covering both turn-based (including tabletop) and real-time (including MMO) combat, which means this will be a pretty long one. I hope it makes up for no update on Saturday.
We really can't discuss this in a vacuum. We have to talk about options each side has. There's really no "vanilla" option, either. For real-time games, do melee characters have gap closers? Do ranged characters have escapes? Are attackers rooted while they attack? Are only melee attacks rooted, or ranged? Can ranged characters attack while in melee range and if so, how effective are their attacks? Are there dead zones where ranged characters can't attack? Is there any sort of movement slow or other escape prevention mechanics for melee characters? What about for ranged characters? Are there ranged slows or CC to prevent the enemy from closing? And of course, how much reward is there for getting in close as a melee? How much reward is there for keeping away as a ranged? What about resources? Do ranged characters have to expend resources to attack?
Turn-based games have similar considerations. Is movement a "free" action, or does it take from the action pool used to attack? Is there any game rule preventing ranged attackers from retreating (attacks of opportunity)? Are ranged attackers prohibited from moving and attacking in the same turn?
If you think to games you've played, you probably realize just how different games can be. There's really no benchmark set of options for melee or ranged characters in any game. If you think on even shooters, many of them have a shotgun which is essentially a melee attack. It deals effectively zero damage at "normal" ranges and deals lots of damage at "close" range. Even if the game has a melee attack, the melee is probably an opportunity weapon or an attack of last resort, while the shotgun is closer to a "real" melee attack in another game where you're basing your strategy around its use.
Advance Wars style: Restricting ranged attacks and movement
Advance Wars honestly isn't the first game to have artillery units that can only shoot if they don't move. However, it's the first game that comes to my mind. I'm sure some retro gamers are shaking their fists at me right now.
I like this style because it inherently makes ranged weaker than melee, which I kind of feel is easier to balance around as a designer. Making powerful ranged attackers make it really hard to make melee good. GW2 actually sort of does this too; you can't run backwards or strafe as fast as you can run forward. If a ranged character turns and runs, he can't shoot back but he can get away... in theory, anyway (in practice, melee characters have lots of gap closers so that's not the most viable option). Restricting ranged attackers' ability to fight back and run away at the same time greatly limits their power and in turn, makes them easier to balance.
You actually have to give ranged attackers a lot of help in this situation. You would think that simply having ranged attacks where melee can't retaliate would be enough, even if they can fight back at 100% in close range. Honestly, you almost have to make your ranged equal to your melee in terms of tanking hits, since they can't retreat and attack, but melee can chase and attack.
Even though GW2 is a real-time game, I think it does this pretty well. The problem is that ranged characters are a bit same-y with melee characters, and you end up having a sort of similar experience regardless of what class you're playing. This works a bit better for war type games with lots of combatants, but if GW2 is any indication, forcing ranged attackers to choose between attacking or retreating (and then giving them some bells and whistles to help them deal with melee) is a pretty solid way to design and balance a real-time system.
Tactics-style RPGs: Movement is (mostly) free
Most tactical RPGs have a discrete order of operations in a turn; a character can both move and take an action. Many games allow you to do them in any order, but others require a character to move first. In any case, moving doesn't prevent the character from using his or her full range of attacks. Sometimes, skipping either or both actions lets the character act again sooner; this is mostly for time-based systems rather than discrete turn/round based-systems.
First we'll talk about "move and act in any order" since covering "move and then act" is easier once we've covered the basic groundwork. Ranged is obviously advantaged in this type of system. In most situations, ranged attackers will be able to attack first. Melee attackers need to abuse fog of war or other forms of imperfect information (such as stealth) in order to gain an advantage. The more imperfect information is present in these kinds of systems, the more melee benefits.
Note that if the time to kill is relatively long, some of the ranged advantage is lowered. This is because melee attackers get to spend more time in range attacking. Although ranged attackers can retreat and attack, if all things are equal, melee will simply chase and attack. This does allow ranged attackers to exploit advantages of terrain better, though. If the game is "move and then act only," it can be really painful for ranged attackers if they can move farther than they can shoot; either they move their full distance and still get chased down, or move less and potentially get surrounded, but get to fight back.
The biggest problem though is that ranged teams get to focus fire. In any of these kinds of games, you would want ranged attackers (it's just a given) just for this reason; you generally can't put multiple people in the same space (hex, tile, whatever), so many melee characters might not be able to attack simply because they can't get to an open adjacent space. This problem gets exacerbated as more units enter the game. Consider a game like Langrisser where you have huge armies of dudes; movements get really clumsy and irritating.
Overall I don't recommend this design at all. Ranged is too naturally favored and melee needs to be given too many concessions to be good. It creates very binary gameplay that is probably bad and really hard to balance.
XCOM: Action point tactics systems
Some tactical RPGs like the XCOM series and the old Fallout games use a different style of movement. Both movement and actions use the same pool of points. Much like the previous example, ranged is favored. All the things like focusing fire, preemptive attacking and controlling terrain are also true of this.
However, action point systems are generally worse because creating distance is part of the action economy instead of a separate, discrete action that you're forced to take. Adding free "movement only" action points does help, but not really. As melee, you literally can't close the gap to the enemy if they can all focus you afterwards, because you spend most of your offensive potential just getting in, and the ranged enemy gets all of their offensive potential immediately afterwards. Generally, a full turn's worth of action points in these games is enough to kill a single character, so you get behind on units (and therefore action economy) very quickly.
Melee needs to be very, very overpowered in order to survive in these kinds of systems. It's very telling that the modern XCOM games are completely imbalanced and it's clear the designers did not care to balance the game at all. I'm not really a big fan of that kind of lazy design, where you just put a bunch of OP stuff in your game and don't care how good it is because any of it can beat the game. I'll probably rant about game difficulty at some point too, honestly.
MMOs: Real-time attacking of all kinds
It's pretty common in modern real-time games to have attacks that root your character. WoW actually doesn't root characters any more, unless they use spells or some other specific actions that root your character. I remember when hunters couldn't move and shoot. Sigh.
Characters that can move rapidly in all directions and/or shoot backwards while retreating are really awful. It's basically the same as tactics-style systems but in real-time. Ranged has huge advantages, etc. Most of the melee versus ranged debate comes from this kind of game, and it's freaking obvious that ranged is good if they're allowed to attack and run away at the same time. Slow down backwards movement and keep characters from shooting out of their rear!
As a designer you have to give so much to melee to help them succeed. Movement snares/slows, CC, tankiness, gap closers and so on. You can give those things out but it kinda sucks to be forced to just because your game system is broken to start with.
Rooting while attacking is... only slightly better to be honest. If ranged is rooted and melee isn't, it still gives ranged an advantage but much less of one. You can add tankiness to melee and be a lot better off. If both are rooted while attacking, combat is just clumsier. Ranged characters have the same basic advantages as the tactics-style games; a lot more if running out of attack range while an attack is animating causes it to miss (which is common in many games like this). Even if it doesn't it generally puts a lot more forced skill on the part of the melee character. Definitely not a desirable thing.
D&D/PF: How to do it really wrong
I don't even know where to begin. It's basically the least balanced thing imaginable from a pure systems standpoint. I'm going to talk a little bit about specifics of this system because there are specific mechanics that make this system totally broken.
Melee are pretty limited in options in a core game. They have 3 basic options: Move and attack once, do a full attack but don't move (well you get a single 5' step), or double move in a straight line (charge) and take a single attack, but get a defense penalty. Ranged attackers have pretty much the same options, but we can also consider withdraw (double move, first square doesn't provoke) as an option as well. The options in this system are fairly clumsy but it is a PnP system (and thus more of a realism simulator) than a gamist thing like wargaming or tactical RPGs or real-time MMO combat.
Oh, also ranged weapons can shoot many times further than the standard movement action. Again, realism simulator. The first problem is that ranged attackers can take one or more full attacks before melee attackers can even close the gap. Additionally, if a melee attacker uses charge to attack one ranged enemy, other ranged enemies can use their full attacks to hit the charger and it's much easier because he charged. That seems totally fair especially because the charger gets a single attack. There is a penalty to hit an enemy engaged in close combat with a missile weapon, but the charge penalty effectively halves it and there's a feat to remove the penalty to hit enemies in close combat.
Now there's a catch here. Ranged characters can't use their ranged attacks in melee range without provoking an "attack of opportunity." However, they can simply use their single step to move out of melee range and then take their full attacks. In a magical world where all the melee attackers were to charge all the ranged attackers (thus forcing a threat of a full attack on the next turn), the ranged attackers still have the luxury of focus fire, while melee characters really don't.
Keep in mind that in D&D, the best ranged weapon users are also the best melee weapon users, so the actual tankiness of the ranged attackers is likely to be similar. The melee attackers are likely to deal more damage, but the ranged attackers are likely to be harder to hit. One or the other is likely a bit better than the other but it's not really important; they're roughly dealing the same damage overall when they attack.
This is further exacerbated by the fact that any sort of magic generally favors ranged attackers. Movement buffs like haste are the exception; even though they give the same effective combat benefits (+1 attack, +1 AC, and +1 hit) they give movement which favors the melee attacker. Movement slows, fatigue, entangling, and all sorts of conjurable terrain favor ranged characters who can deny melee characters an approach. One would think summoned creatures would be a benefit to melee (due to flanking), but not really; because charges are forced to be a straight line without obstructions, ranged characters can use summoned creatures to completely forbid a melee's best option to close the gap.
Probably the worst of it all is that all those magical effects presented above are on characters that are predominantly ranged -- mostly because magic is the best option in general and magic is generally ranged. The best part? Casting defensively allows spellcasters to cast right in front of their melee attackers! Magic is insanely OP in general but the fact that mages get an answer to melee that even archers don't get and is also trivially easy is just a slap in the face.
The moral of the story: Don't emulate D&D's combat in any version. It's really, really, really bad. In 2e when movement was abstract, the combat was probably more balanced than it is now (in 3.5/PF/4e/Next). If I ever design a wargaming-style strategy game, it will probably take a lot from Advance Wars; if (when?) I release my tabletop ruleset, it will also avoid as many of D&D's pitfalls as possible.