why could the court not find that there is no longer a risk to the security of the free state to necessitate such militias?
Because the constitution does not give the court that option. If you are so insistent (and I commend you for it - honestly) that we look at the full text of the amendment, you should pay careful attention to the structure and grammar of that text:
"A well-regulated militia,
being necessary to the security of a free State . . ."
It does not say "If a well-regulated militia is necessary. . ." or "As long as a well-regulated militia is necessary . . ." or "To the extent that a well-regulated militia is necessary . . ."
It says that a well-regulated militia IS necessary. It takes a constitutional amendment to determine that a well-regulated militia is not necessary. The court simply cannot (without being disingenuous) determine that it is not so.
Ron, congratulations. It takes a special kind of guy to make me start sounding like an NRA apologist (which I adamantly am not!).