They are practical, for the same reasons a knife is practical. This isn't opinion either.
SWAT research has determined that a pistol vs someone with a knife at 15 feet, knife wins. An expert with a knife can get 6 lethal stabs in before someone with a pistol can make use of it.
In the case of a bayonet this range increases as now we've added the guns length to the knife, thus increasing the amount of distance someone can cover.
It only takes 1 lethal stab.
To put it in perspective the average healthy human can cover 120 feet in 6 seconds, divided out that's 20 feet per second.
In a close range situation of 15 feet you only have .75 seconds to acquire a target and fire, guns require alot more accuracy to effectively stop a target then most people can acquire within .75 seconds.
SWAT determined the effective safe distance to stop a target with a pistol or other sidearm, that is armed with a knife, is 21 feet. Which is roughly 1.05 seconds to respond and fire.
A bayonet fixed to a rifle would add a few feet to this distance, and anything under 21 feet would result in the man with the gun suffering possibly fatal stab injuries.
Let's also not forget newtons law "An object in motion stays in motion" even if you successfully shoot someone who charged at you full tilt, they will continue moving forward and that bayonet was already pointed at you, it won't stop because you got a few lucky shots off first.