It was impracticable to defend the Louisiana Territory from potential invaders - Britain or US might march in at any time and simply take over.Better to sell the land and get something for it while that was still an option.
Napoleon needed money to fund his wars of conquest and aggression in Europe - one of the terms of the Louisiana purchase was that the US had to pay the whole price up front in gold.
Selling the Louisiana Territory to US would increase the power of that country in the long run,which would make them a rival for Britain - Napoleon's most hated enemy - later.