Because it was animal feed. A good modern analogy would be putting a unit of soldiers to eat dog food - not necessarily something that would be harmful in the short term, but something that would be considered to be exceptionally unpleasant, and which all the soldiers would want to get out of doing as quickly as possible. The reason for them getting into that mess would be very apparent (generally these things were a punishment for a unit's bad behaviour) and they would have exceptionally good incentive to not do the thing again. Oftentimes, the downgraded rations would be accompanied by forcing them to sleep outside the army camp as well, a more physical and literal form of "sorting out the bad apples" that was the second half of this punishment.
Soldiers who were outside the walls of the camp were subject to a "mini banishment," and they knew the subtext, even if they were in a safe land. They would not be protected by the walls and the sentries and the swords of their fellow countrymen: they would be able to be preyed upon by any hostile entities who happened to be passing by. Sure, they might be allowed in the camp if an attack happened - but not before they took a hit. The social aspects of this distancing were crucial as well: the rest of the army couldn't help but be separated from these miscreants. Soldiers certainly wouldn't want to come over for dinners, and no one wanted to be associated with the people who weren't allowed to be up to the snuff of other soldiers.
So for the people themselves, it was dehumanizing in more than one way - and it wasn't just the barley that was the reason. It was what the barley was (animal fodder). It was the other things that went with being forced to eat barley. And it was the judgement of all of their fellow soldiers. Camaraderie was essential in ancient armies as much as it was in modern ones, and the stain of being "otherized" in this manner wasn't something that would just go away or be forgotten: these guys would be dealing with the stigma for years afterwards. Sorry for the relatively short response, but let me know if there were any further questions!
Discipline in the Roman army was spectacular.
Soldiers who endangered their comrades by negligence were punished harshly, and sometimes capitally. The first-century general Corbulo executed two soldiers simply because they failed to wear their daggers while digging a trench.^(1) The Republican hero Titus Manlius Torquatus supposedly executed his own son for disobeying orders. A whole series of generals - most infamously Crassus - subjected mutinous or underperforming units to the terrible punishment of decimation, in which every tenth man was killed by his comrades. Soldiers found sleeping at their posts, stealing from their comrades, or lying were beaten to death.^(2)
These punishments probably loom larger in our literary sources - which tend to be concerned with exemplary deeds of valor and Roman virtue - than they did in actual practice, not least because decimation and summary executions weren't great for morale. It was much more common for commanders to use less dramatic measures to set apart and humiliate the disobedient and the cowardly.
Individuals were normally beaten or switched in front of their comrades. But units that had failed to do their duty faced more symbolic punishments. They could be denied the right to wear the broad military belts that marked them as Roman soldiers. They could be forced to camp outside the stockade that marching armies erected around their camps. And they could be placed on rations of barley, instead of wheat.
In many parts of the Classical world - including Greece - most bread was made from barley. But in Italy, almost all bread was made from wheat, and barley was generally reserved for animals.^(3) Forcing men to eat barley - the lesser grain, the fodder of beasts - was nothing more and nothing less than a means of advertising a unit's shame and exclusion from the rest of the army.
(1) Tacitus, Annals 11.18 (2) Polybius 6.37 (3) E.g. Pliny the Elder, Natural History 18.94
My Thing is the Peloponnesian War, not Roman punishments, but this isn't actually entirely a history question, so I feel OK answering. The relationship between barley and wheat was then the same as it is now, by and large.
They have some similarities: both crops are cereals, meaning they store well without ice or refrigeration, provide lots of carbohydrates, and are suitable as staple foods for someone on the move (like a soldier).
Difference the first: barley is easier to grow in the Mediterranean than wheat. This is chiefly because wheat requires one and a half times the annual rainfall for a successful crop than barley does!
Cereals could be grown on most plains surrounding the Mediterranean, but irrigation was not as practical as in other cradles of ancient civilization, so availability of sufficient naturally-occurring fresh water really made a difference. R. Sallares' claim that the classical Med did not have an appreciably different agricultural climate from the modern one is widely accepted, and today some agricultural areas have enough rain to have grown barley using classical methods, but not enough to grow wheat. Furthermore, many areas have highly variable yearly rainfall, meaning some years wheat would be practical and others barley would prove a more reliable crop, so even in some places wheat could be grown, the surefire success was preferred.
Difference the second: wheat is a more pleasant food for humans to eat than barley. I can justify this claim historically, but a shortcut might be: when's the last time you had wheat bread? OK, now when's the last time you had anything primarily made out of barley other than beer? This ought to intuitively demonstrate that, in an environment where both are easily available, one of the two is highly preferable.
So: we have two cereals, both of which will keep you alive, but one of them is riskier to grow (and therefore rarer to find) and more pleasant to eat. These factors combine to mean that if you were fed wheat, that was a positive statement about your value. If you were fed barley, that was another statement: "you're worth keeping alive, but not more than that." A soldier eating barley porridge would naturally have emotionally compared his lot to that of a pack animal, making it an effective punishment.