It would depend on when you are asking, as you get later in history, bayonets are less effective due to repeating firearms and then automatic weaponry.
However, up until the mid-19th century, the bayonet was a very effective method of attacking an enemy. During the Revolutionary and Napoleonic Wars, the bayonet was the primary method of fighting for the French armies. During the Revolution, commanders benefited from the tactical theory of the previous decades which had a lot of discussion of line versus column. The main idea was that line formations were good to fire volleys while column formations were easy to control and best for bayonet charges.
With this, the Revolutionary armies, in the beginning, would focus on column attacks with support of "clouds of skirmishers", citizen soldiers would be pulled together into proper columns and bayonet attack (column attack) the professional armies of Europe. It was quite effective and can be seen in the formations that were later adopted, l'ordre mixte, which I explained here during the Napoleonic AMA.
However, for a pivotal role, you need to look no further than the Battle of Wagram in 1809. During the last day of the Battle, the French army was exhausted and was lacking a viable means of attack. So General MacDonald pulled his corps together and said to Napoleon to support him, because he was doing a column attack with his entire corp. So, think about twenty thousand men (more maybe, I don't know how many men were in his corps) in columns of say ten men wide and however many deep, marching then charging at the middle of the enemy Austrian army, also equally exhausted. It was the stupidest thing to do since the Austrian artillery could have easily destroyed it and there were attempts to encircle the column, but it worked and was the right thing needed to finish the battle. Because of the overwhelming numbers of men charging an exhausted middle, Napoleon was able to exploit it and destroy the Austrians at Wagram.
So, during the Napoleonic Wars, the bayonet was very important and the primary method of attack at the small level.
Often, I joke with a friend about this thing. We joke that a French line colonel would see a defensive position and ask when he was supposed to charge the enemy, the idea is that a colonel would be focused on the attack rather than defense.
Bayonets were effective in hand-to-hand combat situations, however they weren't always used as widely as believed. Many troops during World War I downplayed the use of their bayonets in actual warfare claiming that they mainly served a more utilitarian purpose such as cooking, opening cans and cleaning mud off of uniforms. However before troops went "over the top" one of the commands were to "affix" meaning to put their bayonets onto the front of their gun. Despite a lot of the combat during the war being barbaric hand-to-hand fighting, many soldiers preferred using alternative methods of such as clubs and brass knuckles.
However, there are some instances where bayonets were used regularly: "...when a raiding party had reached the enemy position the role of the bayonet was often primarily one of guarding the grenadiers among their party, whose task was to race down the trench lobbing hand grenades into dugouts as they passed. Indeed, bombing parties invariably contained at least two 'bayonet men' whose job was solely to defend the bombers." [Source] (http://www.firstworldwar.com/weaponry/bayonets.htm)
Even during the American Civil War, bayonet's effectiveness was more psychological then physical: "Seeing a few thousand people running at you with large knives on the end of rifles could have a pretty frighting effect. You might come up with an excuse to leave real fast. However despite this only about 1% of Civil War casualties were actually a result of a bayonet wound." Source
I don't think the bayonet turned the tide of any major battle or won any war, but it definitely helped both psychologically and physically for both sides. In a pinch it can be used to well...do its job. But it wasn't something that troops would rely on heavily. Bayonets were easy to stab with, but as bad as it sounds if not done properly, could get stuck in the victims body and be extremely difficult to remove. It would've been better to punch, slice and later on shoot someone rather than stab. While nearly all troops on both sides were equipped with bayonets, they were probably used more as a utility knife than an actual weapon of war.
According to American military historian Alan D. Gaff, beyonet attacks were pivotal during the Northwest Indian wars (1790s). Here, General Anthony Wayne instructed his troops to attack with beyonet and skalking after large scale artilary blasts. See Gaff's Book "Beyonets in the Wilderness"