I have mentioned in other answers that I was around as an adult when the Apollo programme was happening.
The following was "common knowledge' around the time of Apollo 11, as read in newspapers and books, so common I never thought that I would grow old enough to require references for what were "current affairs" for me.
NASA was formed with the early part-reason to reduce the sometimes bitter inter-service rivalries over which service would or could put a satellite in orbit. America needed all of its experts to work together.
It was always reported over the years when the Apollo programme was still current affairs for me, that Neil Armstrong was a civilian and that, alongside his technical abilities and academic training, was a prime reason why he was chosen to be the first man to set foot on the moon (and thus prevent an apparently ever-present worry of inter-service rivalry rearing its head sufficiently via "bragging rights" to compromise the high level of teamwork needed for NASA to operate efficiently).
I never heard of any other major reason why Neil Armstrong was chosen, and I did hear the "civilian" reason touted many times, for his choice among many others of equal competence.
However, although not publicised as such as a factor for his being chosen for his role, Neil Armstrong was known at NASA to be cool under threat of imminent death. He was seen - and the live video of the crash probably still exists on youtube although I haven't looked for a while - bailing out about one second before the crash of the out-of-control LLRV (lunar landing research vehicle) he was flying, impacted the ground. Later in the day, he apparently astonished his fellow astronauts by working quietly away at his normal tasks in his office like nothing had gone wrong with his day.
The question does raise the issue that by virtue of existing aeronautical tradition if nothing else, Buzz Aldrin should have been the lunar pilot and therefore should have been the first man to set foot on the moon. But he was a military man from a military family, and that would have counted against him, nothing to do with ability to do the job. Many articles were written around late 1960s-early 1970s of his prolonged efforts to be the LM pilot and thus be the first man to walk on the moon. Never once was his competency questioned, as I recall.
Edit: Addition to clarify that I answered the question "Why?" Point taken that there is more than one "why" about the choice of Neil Armstrong in the pilot's place in the LM.
I did dwell, above, on the "civilian" aspect why Neil Armstrong was chosen to fly the LM. It was consistently and widely publicised in international media. Could every reporter have gotten it so wrong for decades, without picking up the phone to NASA or having NASA call the major news feeds and say "you got the (civilian) reason wrong"?
But the question as put here here was fairly asked, and I was fairly reminded in a comment below, that my "why" answer, above, was maybe a bit limited in its breadth. Question: why was Neil Armstrong the LM pilot? Answer, worded in a different way so it covers more aspects of "why": because Neil Armstrong was in the pilot position, because he was to be first out the spacecraft hatch, because he and Buzz Aldrin couldn't swap places when suited up in the LM therefore Neil had to be nearest the hatch, because both Buzz and Neil were competent fliers of the LM so the question of who was the better pilot didn't arise, and in this most critical procedure of all time - the first landing on another world with no chance of rescue if things went wrong - it didn't hurt to know down at NASA that Neil was the one who had tangibly displayed incredible coolness under life-threatening danger with the LLRV crash.
So that is why Neil Armstrong flew the LM when Buzz Aldrin was the LM pilot.
I see that Deke Slayton has been quoted from his autobiography in a comment below, what he had felt in 1964 about how he chose astronauts. It's his autobio and one should respect that. However, the international news reports of US military rivalries and the damaging effect of a lack of co-operation between the services on a matter of international prestige, dated back to shortly after 1957 and Sputnik 1 - long before Deke's memories of his feelings in 1964. This was also a time of embarrassing American failures from different arms of the military around that time to get a "face-saving" satellite into orbit. NASA had to demonstrate that there was no place for egos of any kind as it settled down and focused on doing a job well, with eventual awe-inspiring success. That "unspoken" awareness had to have been in the NASA "psyche". The plentiful evidence of history strongly suggests why Neil Armstrong was to be given the ultimate prestige of all time rather than a military man, as he went on that journey carrying President Nixon's message, "We come in peace [not war] for all mankind."