Going back, in ancient Rome 21 was commonly the age of majority. In the Bible--specifically the Book of Numbers--20 is given for some purposes, including military service. And of course, the "age of consent" for sexual purposes has varied and does vary by jurisdiction today.
It is only by the converging of various factors that 18 has become the focal it has. One can vote, enlist in the military of their own accord, smoke tobacco, live on their own of their own accord (more on that later), and buy a long gun at age 18 per federal law. People generally graduate high school around their 18th birthday as well, and many financial services only become available at age 18.
Yet that is not universal. People can generally drive at age 16, though driving while using a cell phone or comparable device (save for CB radios) might be restricted until they hit 21 (if a jurisdiction allows it at all). I saw in a major discount chain that one had to be 16 to purchase a machete there. And of course, drinking outside of a family setting is prohibited until age 21 in the United States.
The reasoning behind all of this variance in age requirements--public and private--is the realization that humans take time to mature, and even after their bodies are fully functional, their minds take time to form. That mental formation is a process, with gradually increasing levels of judgment and responsibility. Mark Twain famously spoke of leaving his father at age 18, considering the man a fool. At age 21, he saw his father again, and was amazed as how much he--the father--had learned in those three years. Obviously, the import of the statement was that Twain himself had matured by virtue of his living those three years more, and thus wisdom in his older relative where before he had seen foolishness.
Indeed, it is those three years--18 to 21--that have become the focal. The latter is no longer the default it once was, yet the former is not, as stated before, fully set.
Since 1968, handgun purchases have required being 21 or older. The idea was to restrain youth gangs, with the view that greater maturity was called for in responsibly having such a concealable arm. In our Common Law society, one's rights, including self-defense, are much more restrictive when one leaves the home. This is because one is now in the community's area of interest, rather than one more explicitly their own. "A man's home is his castle," but on the other side of the moat, the community has its say.
Long guns, though, were seen differently. People at 18 were seen as responsible enough for actions such as hunting. Long guns were--and are--less used and suited for most common criminal activity, including--perhaps especially--youth crime. And of course, there was the issue of such a personal being able to defend his home and person.
Of course, being pre-Heller, 2A and its Right to Arms really bore no legal bearing on these age settings, though it would have influenced the political debate.
In recent years, due to mass shootings by young people in that age range with long guns, movements have arisen to raise the long gun age to 21--with exceptions for those in military service--based on similar concerns. The military exception is based on the accelerated maturing--training and discipline--effect that military service tends to have on people. Add in, of course, that a person being trusted with a modern military rifle, even if borne while under military authority, would call for such a person being trusted with civilian analogs in their private lives.
Now, with that background and basis, let us examine objectively the application of age ranges to RKBA. Libertarians arguments will be largely ignored, as their proponents tend to give no credence to Common Law and constitutional jurisprudence and would have nutcakes carrying machine guns in public.
The Right to Arms extends back literally centuries to the Old Country. A key point of legislation and codification on it was the 1688/89 English Bill of Rights:
At its base interpretation, it was held to guarantee the right of a peasant to keep "a blunderbuss to ward off burglars." In other words, home defense. I have pointed out how early colonists traded their blunderbusses--"blunderbi"?--for full-size muskets and such for the challenges they would face in the New World (TDF 10). And from that, our more expansive 2A descended, with that concept of home defense--a most basic point in our Common Law tradition--at the "core," in modern jurisprudential parlance.
From this it is obvious that if one is maintaining a home, then one generally has that same sort of right, both to defense in general and to the tools of that defense in our modern era. This is all the more true given that fact that an 18-year-old can be FORCED to maintain a household. That is the age when parents can legally kick ungrateful brats--or any brat, for that matter--out of the proverbial nest. That is a failing of a general prohibition on firearms for 18-20-year-olds, no matter how well-meaning--even with the military exception. SOMETHING must be excepted. A person that age on their own has a RIGHT to something for that core purpose.
Today under 1A, journalists--even fake news insurrectionists, apparently--are protected in using modern information technology as comparable to the hard-copy printing presses of old. Likewise, 2A practitioners are to be protected in using modern firearms as comparable to the blunderbuss. But unlike the stretch of development line necessary to equate computer technology with printing presses, in the arms realm today, there is a direct technological descent from then to today. Experts on the history of firearms development over the centuries--honest and objective ones--will hold that the modern descendants of the blunderbuss are the carbine (TDF 49) and the home-defense shotgun (TDF 43/44). Thus, at a minimum, something along those lines--a HiPoint or a Mossberg--would be constitutionally protected for those 18 to 20.
But the real factor on handguns in this regard is the matter of "bearing." It is here the best chance for overturning the ban exists. But to pursue that first requires the Court to render judgment on out-of-home carry in general (see TDF 68 for more on that). But even with a SCOTUS decision upholding traditional regulatory power on local carry, there would remain the issue of long-distance traveling. "Bear" was an American development on the Right to Arms, and its explicit mention in 2A should be held to at least guarantee some sort of being armed while on a journey. This is where handguns come in explicitly, as in our modern times CCW is the standard. That said, an argument can be made that an 18-20-year-old can transport his above-noted "modern blunderbuss" on a trip as a carveout, as it would at least at a baseline provide for the intent of defense of self and others.
UPSHOT: There is room for age-based distinctions within RKBA (and there should be with other rights as well.) It goes to the nature of the right. Those 18-20 are 2A-guaranteed a carbine or shotgun for home defense, and travel with it.
This is, of course, a minimalist interpretation and analysis. An honest court applying strict-scrutiny would likely be more expansive. The problem we face--and this is what TDF is intended to prepare Patriots for is the reduced RKBA destined to come. "Principle" is not the issue. Firepower is.