Of itself, of course, it would not lead to the end of Napoleon.
It was a constant drain on the manpower and resources of the Empire and was probably the one area that did not pay for itself.
Troops in Spain
From Napier
July 1810 - 349,972
August 1810 - 351,961
January 1811 - 361,838
April 1811 - 331,776
Other sources
July 1811 - effectives: 291,414
April 1812 - effectives: 230,187 after withdrawal of 27,000 for Russia
In a memorandum of October 1811, Napoleon remarks that while troops in Spain must on the whole remain, only cadres from certain battalions could be withdrawn.
It was also a constant reminder that under the right circumstances and conditions the French Empire could be resisted. A point perhaps not lost on Alexander. One can discuss whether or not Alexander would have taken the course he did if there wasn't fighting in Spain and the full might of the Empire would have fallen on Russia.
It could be considered a factor in the resurgence of the Austrians in 1809, the Empire's defeat at Aspern-Essling and its hard fought victory at Wagram. A war that further drained the resources of the Empire including experienced officers and men (Lannes, La Salle etc.)
Leaving over 200,000 veterans in Spain in 1812 and 1813, while fighting a major war against Russia and then relying on new conscripts in 1813 has to be a contributor to the defeats in Central Europe and the eventual withdrawal. In January 1813 Napoleon only ordered the withdrawal of officers and cadres to rebuild his army. While in 1814 having to fight on the northern frontier with smaller armies while leaving some 116,000 men fighting in the south made it near impossible for Napoleon to win in the end regardless of his hollow victories. Only when it was far too late did he remember he had veterans in the armies of Soult and Suchet and made peace with Spain. Deluding himself that the Spanish would ratify such a peace and free those troops for his own use.
But in my opinion, the Peninsular War's major contribution was that it kept Britain in the war. It was the one area where Britain could now confront the French Empire on the continent. The string of victories coming after Corunna and Walcheren could only increase the home morale making the war acceptable if not popular. It freed up the Royal Navy from having to blockade Spanish ports. It also opened the South American markets to British goods thereby increasing its wealth to continue the war and subsidize any future Allies.
Ron