One of the main reasons for the creation of these laws was due to the 13th Amendment to the American Constitution which stated that slavery will be abolished (to get rid of)
EXTRA VIDEOS THAT EXPLAIN THIS IN DETAIL
A very detailed video. If it's too much, forward to 6 minutes and watch from there. 12:45mins is the point where the Civil Rights movement is discussed.