Anything less than ideal can be reworded to be a "lack" of whatever would make it ideal.
This flawed diamond has a lack of perfection for use in jewellery.
This 9% alcohol beer has a lack of lightness.
Children trying to enter the workforce have a lack of age.
And so on. It doesn't make sense to describe flawed diamonds, strong beer and children themselves as "deficiencies" because we don't normally think of these problems as deficiencies. Bad diamonds are thought of as including flaws, strong beer as having too much alcohol, and children as simply being young.
Similarly, we think of social inequality as a simple state of not being equal, rather than some "quantity" of equality being lacking, and an economic shortcoming is considered a flaw in structure, rather than a lack of perfection.
"Deficiency" is only naturally applied to contexts where we naturally think of those things as a "lack".
People who never go outside are deficient in vitamin D.
This company has a staffing deficiency.
Mario Mendoza was famously deficient in batting talent.
We think of unhealthy organisms as lacking nutrients, and understaffed companies as lacking staff, and bad athletes as lacking talent.