A hundred and fifty years ago, most states had a law which prohibited interracial marriage. States that did not, or which did but then repealed them, felt compelled to placate their neighbors. The result was laws similar to the one in Massachussetts, which holds that out-of-state couples could not get married in that state if their marriage would be illegal in their state of residence.
As more and more states repealed their antimiscegenation laws, states that wanted to keep theirs felt themselves forced into taking a different tact: residents who got married in another state faced criminal charges if they ever returned to their state of residence. This was the situation in
Loving v. Virginia, in which the US Supreme Court struck down the last remaining antimiscegenation laws in 1968. In that case, Mildred Jeter (who was black) and Richard Loving (who was white) left their home state of Virgina, where interracial marriage was illegal, to get married in the District of Columbia. When they returned and took up residence as husband and wife, they were arrested, found guilty of a felony and sentenced to one year in jail. The sentence was suspended for 25 years provided that they left the state and never returned during that 25 years.
The Wisconsin law in question is very similar to the Virginia law, except that it is not explicitly racist. Rather than criminalizing interracial marriage directly, it criminalizes the situation where Wisonsin residents leave the state to enter into a marriage that is illegal in Wisconsin. When statute 765.04(1) became law, this meant interracial marriage. Thanks to the Wisconsin constitution being amended in 2006, today it means same-sex marriage. Heterosexual residents of Wisconsin who are married out of state are not liable to criminal prosecution, as they (most likely) could have gotten legally married in their home state. It is currently an anti-gay law, but it is incorrect say that it was designed as such; it was meant to be racist.