Whole books have been written on this...
Basically, the country spent most of its first 80 years of independence having civil wars. Most of the wars were between people known as the liberals (like Benito Juarez) and those known as conservatives (like Santa Anna).
In addition, Mexico had to undergo invasion and occupation by the French and Emperor Maximilian (which was connected to the liberal-conservative wars).
Finally, Mexico found stability during the Porfiriato (1870s-1910). But this came at a price as Diaz established authoritarian rule and, it can be argued, was only concerned with helping the rich and foreign investors.