The Legal Test for Security Clearance
To be granted security clearance, an assessment must be made that it is "clearly consistent with the interests of national security" for the person to be cleared. Any doubts about this are to be resolved in favor of national security - meaning on the side of denying the clearance.
From the sounds of it, one might wonder how anyone gets cleared under this test. In practical reality though, most Americans who apply for clearance are granted clearance. Only a small fraction of the applicants are proposed for denial and some of them are eventually granted clearance after going through the formal review process for challenging the initial decision/proposal to deny.
This does not mean that the legal test is meaningless or not being applied, however. It simply reflects the reality that most people who apply for clearance are solid citizens who have their houses in order and don't have things in their life that make them vulnerable to blackmail or coercion so as to outweigh their fundamental loyalty to the country. For the most part, in my experience the judges and adjudicators making clearance decisions are applying the legal test in a common sense way that reflects the balancing called for in the test in light of real world factors.
I am often asked if it's possible to be denied clearance at one level - a higher level - but be granted clearance at the same time at a lower level. This is not legally possible because a decision that it is not consistent with the national interest for a person to be cleared means the security of classified information would be placed at risk by giving the person access, and ALL classified information, regardless of the level, is information that will place the nation's interests at risk if made known to our enemies.