The classification is based largely on a combination of containability and danger, though the former has become weighed far more highly in recent years of the in-universe Foundation.
That is, if an object is completely uncontainable and has a small potential for danger, it will almost certainly be classified highly. If an object is very dangerous but perfectly containable, it will likely be classified closer to Safe.
The reason why containability is weighed so highly is due to recent recognitions of severe underestimates of how dangerous objects can be, especially sentient ones (which could arbitrarily decide that humanity/the Foundation is their enemy, even if they're neutral or even helpful in the present). This is why the Foundation leans towards trying to contain everything possible, no matter how small or safe it seems, because it could potentially have unknown properties or become hostile at any point.