Answer:
Spain agreed to give Florida to the United States because it was worried about losing Texas to the United States.
Explanation:
In 1803, the United States bought Louisiana from France. This led to a conflict with Spain. In particular, the United States and Spain clearly had different ideas about the extent of the purchase. According to the United States, the new western border was now along the Rio Grande and the Rocky Mountains, while according to Spain, Louisiana only included the city of New Orleans and the west bank of the Mississippi, and the area to the west was Spanish.
Spain initially refused to redraw the borders, but admitted as it increasingly lost power over its rebellious colonies. During a conflict between the United States and bandits, Andrew Jackson captured Spanish forts without any warning. This showed that the ever-weakening Spanish power reached an absolute minimum and put the United States in an advantageous position in further negotiations.
The agreement was concluded between John Quincy Adams, the US Secretary of State and Luis de Onis, the Spanish Minister for Foreign Affairs. It was agreed that the United States paid five million dollars in exchange for Florida. In the West, the United States gave up its claims to Texas and other areas under Spanish rule, and a mutually accepted border was established: along the Red River, Arkansas, and the forty-second parallel. The agreement was signed on February 22, 1819 in Washington D.C. and entered into force on February 22, 1821. One could argue that the boundary found was satisfactory for both parties: Spain retained Texas and a large buffer zone remained between its colonies in California and New Mexico and the American territories, while the United States extended westward to the Pacific Ocean.
Spain did not enjoy the treaty for a long time, because in September 1821 it was forced to recognize the independence of Mexico so that the agreed border became the border between the United States and Mexico.