It is not really possible to answer this with 100% certainty because there could have been a variety of reasons held by the many people who participated. But the usual answer given is that lynching was done to keep blacks "in their place."
One of the major reasons for lynching (or at least one of the major pretexts) was to punish blacks who got out of line. This was particularly true of black men who were deemed to have acted improperly towards white women (Emmett Till being the most famous instance). Whites thought that this was particularly dangerous to their social system because it implied that the black men were good enough to be interested in white women.
So the idea is that black men were lynched to remind blacks in general that they were not supposed to act like they were as good as whites.