Context: the French king Charles X was in a difficult political situation and needed money, so attacking the then-Ottoman-dominated Algeria looked like a good idea at the time. The slave trade had stopped years ago, and the pirate activity, while not over, was way down.