Why did Mexico give up Texas?

Texas declared its independence from Mexico in 1836, and then defeated the Mexican army.