Even though most of the casualties were caused by musket and artillery fire, the bayonet was tactically very important in Napoleonic warfare. A bayonet charge is absolutely terrifying, and the reason why there were relatively few casualties from them is likely because soldiers would break rank and flee in the face of one. If soldiers had stood their ground and fought, casualties would have been much higher, and with their low rate of fire, muskets would have been of little use in hand-to-hand combat.
They key change that happened in the mid-1800s is that firearms finally achieved ranges and rates of fire that made closing with a massed enemy nearly impossible.
Charing into a solid wall of pointy bits is something you understand in your gut to be a bad idea.
See, for example: https://journals.gold.ac.uk/index.php/bjmh/article/download/...
By the Napoleonic Wars, something below 10% of casualties were caused by melee weapons. And even that was mostly cavalry, bayonets account for ~2%. The purpose of the bayonet charge was not to kill your enemy, it was to convince your weakened enemy to cede his position after you had already done the killing. The forces rarely fought hand-to-hand and when they did it was notable, usually one side was so weakened and shocked that they fled or refused to charge.