This is a fascinating question, but one that is, of course, impossible to answer with any degree of certainty. In order to begin to answer the question, we need to look at how the Mexican-American War affected the US. There were at least three major impacts. First, it helped to bring about the Civil War because the balance between North and South was upset when the Mexican Cession was obtained. Northerners felt the war was fought to get land for the South. Second, it helped make Americans more convinced of the “Manifest Destiny” to become a great power. Finally, it meant that California was American territory when gold was discovered there.
To answer the question, then, you have to think about what might have happened if any of these things had not occurred. Let us look at two extreme possibilities.
On the one hand, there is the possibility that the US would have become a small and relatively unimportant nation. The US would likely not have gotten the Oregon Territory from Britain. It would have had no Pacific coast. It would never have ventured out to take Hawaii and the Philippines. World War II, in this view, does not happen. The world is changed in major ways.
On the other hand, there is the possibility that little would have changed. Mexico was no great industrial power. The US would simply have improved its military and fought the war again to get revenge. Mexico would not have had many settlers in California and never would have found the gold. The US would have won the war at a later date and everything would have been the same.
Either of these is possible and it is also possible that something in between would have happened.