Why did Napoleon go to Mexico in 1862?

Napoleon Bonaparte (1769-1821) did not. Napoleon III (1808-1873) was the emperor of France at the time of the Second Franco-Mexican War (1861-1867).

The French were interested in colonizing Mexico to prevent the rising of the United States as a world power by establishing a foothold in the Americas and supporting the Confederate forces during the American Civil War (1861-1865). As a secondary objective, France was interested in exploiting the large silver, copper and iron mines located on northern Mexico.