In general it means everybody, without exception
In this case They slew them to a man is They killed everybody, without exception.
Note that you cannot, as in the question title, "slay somebody to a man" -- you can only "do something to a group of people to a man".
OED1 says
Indicating a limit or point attained in degree or amount, or in
division or analysis, and thus expressing degree of completeness or
exactitude: As far as; to the point of; down to (an ultimate element
or item) to the last man; {to a man} (including every man, without
exception).
And provides some examples
- 1618 Bolton Florus (1636) 149 They might have had the killing of all his Army to a man.
- 1867 Froude Short Stud., Erasm. & Luther ii. 99 The bishops were hostile to a man.
It's not all nasty though, to a man is often used when everyone agrees perhaps in a sentence like this.
After a long meeting they agreed, to a man, to go back to work.
Depending on what your are reading, you might also find every man Jack [of them] as an idiom that means the same thing: every single one [of them] (OED1 again)
- 1840 Dickens Barn. Rudge xxxix, ‘Every one of 'em,’ replied Dennis, ‘Every man Jack’.
- 1859 G. W. Dasent Pop. Tales Norse 347 Every man Jack of them are so sound asleep.