If the British coalition won the Seven Years war, and France handed large parts of North America to Britain, then why would France also give Louisiana to Spain, if they were allied in the war?
The long and short of it is that France had lost the French and Indian War in America and needed to make peace but they'd gotten the Spanish to jump into the war on their side and peace was going to cost not only French territory but also Spanish territory. The treaty itself basically says this (mentions that it's in consideration of Spain's sacrifices during the war). Louisiana was fertile but the whole point was an artery to Canada, which France knew it would lose anyway (the two treaties, one to end the French and Indian War and one to cede the Louisiana territory, were negotiated by the same people). Maintaining French holdings in the Caribbean was far more important.
The treaty was signed in secret and the French population of Louisiana actually drove out the first Spanish rulers to arrive. Even when Spanish control was established, French colonists refused to adopt Spanish customs or the Spanish legal code. In fact, they set up parallel court structures outside the state that held only voluntary jurisdiction. This preserved French law until France resumed control of the territory and set a precedent for the resistance to the imposition of British law when the territory was transferred to the U.S.
Thomas Jefferson decided not to push the issue immediately and the newly democratic Louisiana almost immediately voted to retain French law, enshrining it in their new constitution. 49 states in the United States follow the British common law tradition to this day and Louisiana retains the civil law handed down in Europe since the Roman Empire.
Thank you for the reply.