There was a time not so long ago in which it was a crime to marry somebody outside what was considered to be your given race. That is to say, this law was especially in effect and specifically meant to deal with a white man who desired to marry a black woman. It also quite frankly applied to a black man desiring to marry a white woman; however, in that particular case, the law was pretty much superfluous because mob justice would take care of the perceived problem in its own way, through banishment, intimidation, or much, much worse.
We now know in this present day that the concept of race is a social construct, because biology tells us that there is no “pure” race in all of the world, indicating through these genetic studies that we are all part of a greater whole. So then, when it comes to miscegenation the main reason why this law was the law of the land in so many States for so long has an awful lot to do with the fact that those that were considered to be black, were legally classified as property, so that those that enslaved such could therefore do pretty much whatever that they desired to do with their property, because it was their property, with basically the sole exception being not that the white man couldn’t rape and ravish the black woman -- but rather that it was considered not just bad form, and not just a slap in the face to societal norms when a white man deign to marry a black woman, but also by doing so, this would in its effect, serve to legitimize that which could not be legitimized, because it would serve to interfere with that peculiar institution and could not and would not be countenanced by society, whatsoever -- not under any circumstances, ever. This meant, therefore, that laws had to be put on the books that would stipulate that this was forbidden and therefore not permitted by law.
Indeed, in America, somehow it was perfectly fine and accepted to have all sorts of offspring that came forth from illicit liaisons between black and white, but it was not accepted that black and white could ever live together legitimately as husband and wife. After all, to permit this would be pretty much anathema to the institution of slavery, because it would basically mean that blacks would be, by implication, on the same level as whites, and in this nation in which blacks had no rights which the white man was bound to respect, was therefore never to be tolerated.
Fortunately, the better angels of our nature eventually recognized, but not until 1967, with the Loving v. Virginia Supreme Court case, that miscegenation laws were in violation of the 14th Amendment, which thus meant that miscegenation was now null and void in all fifty States. However, we need to recognize this: the 14th Amendment was ratified in 1868, but prejudices die very hard, and in truth, still live today.