Democratic presidential candidate Joe Biden has won Michigan, flipping blue after the state elected President Donald Trump in 2016.