Why did the Mexican war of 1846 take place

Why did the Mexican war of 1846 take place

Why did the Mexican war of 1846 take place? Was the war necessary? What does this war tell us about this period in American history? Was it God’s plan that the U.S. Extend from the Atlantic to the Pacific, or were imperialists looking for a way to defend what they planned to do anyway