Texas was originally a part of Mexico, and about 10 years after winning its independence from Mexico, the United States allowed Texas to join the nation. It joined as a territory in 1844 and became a full state in 1845.
Mexico became independent from Spain in the 1820s. As people moved into the Texas area, it ended up being dominated by Americans, which led the settlers to rise up and win their independence from Mexico. Texas wanted into the United States after winning independence. The United States delayed the territory's entry because it was a pro-slavery state, which added weight to the South's cause.