How did Texas get its state motto?

Friendship.

The word Friendship was adopted as the Texas state motto by the Forty-first Texas Legislature in February 1930. The word was probably chosen because the name Texas or Tejas was the Spanish pronunciation of a Caddo Indian word sometimes translated to mean "friends" or "allies." See also TEXAS, ORIGIN OF NAME.