Mexico was not righteous. Their banditos were attacking settlers and ranches almost daily at the time war broke out in the 1840s. I believe they deserved to lose that land, and a lot more that unfortunately they still possess.
Every border state (Sonora, Chihuahua, Coahuila, etc.) is an absolute narco cesspool, loaded with cop-killing drug smugglers and paramilitaries that are supporting them. These people don't deserve anything.