Why did Spain decided to sell Florida the US?

Spain did not sell Florida to the US, they sold it to them. The transfer was made in 1819 as ratification of the Adams-Onís Treaty.
Copyright Wanderlust World © https://www.ynyoo.com