There are plenty of examples of slaves being used as soldiers, such as the Ghulam and Mamluks of Egypt, the slave soldiers of many West African empires, and a large number of Brazilian soldiers during the Paraguayan War. It does not at all make any sense to me. Why would one entrust the lowest, least loyal members of society, with a personal stake in overthrowing the government with the means to overthrow the government. Also why would they at all make good soldiers when they're unwilling to fight?
Further question and potential Song of Ice and Fire Spoiler
Would an army like the Unsullied ever possibly have existed or a similar service? Is there any history to castrating males to form a more obedient slave army?
Obviously it did cause problems at times. It was, for example, a serious area of contention for the successor states after Alexander died.
Ptolemaic Egypt and the Seleucid empire both relied on a core of Macedonian pike men, but had to go to great lengths to "import" colonists to fill the ranks. Eventually Egypt allowed natives to serve in the phalanx due to manpower issues, and they ended up causing political instability with their new status.
However, there are several examples of successful "slave" soldiers. Easy examples off the top of my head would be the Janissaries and Mamelukes. They were technically slaves, but were given a high station and good lives for their service.
These were elite, disciplined soldiers with excellent training and morale. Part of the reason it worked is that these soldiers were drawn from groups that normally had little impact or clout. Being a soldier offered them far more power and far "better" lives than they would live otherwise. These slave soldiers were often the most powerful political force in their respective empires.