I was under the impression it began because early slavery was justified because they were not Christian, but when they began converting they needed an immutable trait to base their justification on. Some of this was in the Black Codes of 1664.
en.wikipedia.org/wiki/Code_No...
en.wikipedia.org/wiki/Code_No...