A couple people have given the essence of the story. I’m just filling in.
The U.S. won the Mexican-American War, but treated Mexico fairly. Instead of simply taking the northern states of Mexico, we paid Mexico an indemnity of $15 million. Whoever heard of the victorious country paying the defeated country after a war?
We justified annexing the northern states of Mexico because of the right of self-determination. Those states (Texas, New Mexico and California) choose to join us. Well, maybe the people of the northern part of California. And, maybe the money recognized that there were some disputed regions. Plus, any citizen of Mexico residing in the northern states could become a citizen of the U.S., retaining all their rights and their property. But, anybody who wanted to remain a citizen of Mexico could sell their property and move south.
So, at the time the French invaded Mexico - during our civil war - there were many Mexican-Americans. In keeping with the Monroe Doctrine, they thought we should defend Mexico from the invaders. Like I said, this was during our civil war, so we weren’t able, at the time, to defend Mexico. Come the end of the war, President Andrew Johnson sent General Sherman with an army of 50,000 battle-hardened troops to the border, and told the French to get the hell out of Mexico. Which the French army immediately proceeded to do. The French-installed “Emperor” of Mexico refused to leave. This is my country, he said, I believe in French. The patriots of Mexico arrested him, lined him up against a wall, and shot him.
This is the origins of Cinco de Mayo. It began as a celebration of a minor battle in Pueblo, Mexico, with the expectation that the new country of the Mexican-Americans would fulfill the terms of the Monroe Doctrine and defend its sister American republic.