It should be noted that not only Texas but also California, New Mexico, and large portions of Arizona were once parts of Mexico. The Mexican war mentioned above broke out largely when Mexico spurned President James Polk's attempts to buy California. Mexican influence is quite apparent in these areas in place names, architecture, etc. It should also be noted that the U.S. came very close to war with Mexico during Woodrow Wilson's Presidency. Wilson interfered actively in Mexican politics which caused tremendous resentment south of the border. Also, during that time, Pancho Villa invaded the mainland U.S. in response to which Wilson sent Gen. John J. Pershing into Mexico in a ultimately failed attempt to capture him. When Wilson ran for re-election in 1918, his slogan was "He Kept Us Out of War." Many assume this was World War I, since the U.S. was not yet engaged. Actually, it meant that he had avoided war with Mexico.
The Mexican War that the previous answer talks about had a huge impact on bringing on the Civil War. This was perhaps the biggest impact in terms of historical stuff. In terms of changing our country, I would say that Mexico's greatest role is as a source of immigrants. Mexican immigrants have contributed greatly to the melting pot nature of our society.
The biggest roles came in conjunction with the annexation of Texas. The Americans believed the Rio Grande river was the border and the Mexicans believed the Nueses river was the border of Texas. This land discrepancy led to the Mexican War which was won by the US. The terms of the treaty called for Mexico to give the United State near half of its territory, land that is now much of the American Southwest.