Indeed, Wellington had the advantage of numbers AND terrain, especially when Blucher arrived, yet still almost lost? Was there a big difference in the quality of troops?
It is more of the fact that he won at all that is so important to his fame, than the manner or degree to which he won. He himself stated it was 'the nearest run thing you ever saw in your life' and wrote to his brother that it was the closest he ever came to losing a battle. What was so great, was that he had never lost, had amassed such a tremendous military reputation, but he still had never faced the giant of the age, Napoleon himself. But after Waterloo, he had, and had finally completed the last task to becoming the most famous soldier alive.
There was a difference in troop quality, he had the least veteran of the three armies, and his was the only truly heterogeneous force, containing British, King's German Legion, Hanoverians, Dutch-Belgians and Brunswickers. Of this force, the Duke of Wellington would rely most heavily on his veteran English and King's German Legion troops. The Hanoverians were very raw, as were the Dutch-Belgians. The Brunswickers and Nassauers were practically strangers and untested. But as you say, he did have the geographical defensive advantage, which cannot be understated in this case.
Napoleon's force was one of the finest he ever commanded, but you could consider it to be a glass cannon. They were largely veteran, but didn't have time to get used to their new commanders and units, and had an intrinsic morale problem stemming from the last few years of defeat and the return of the Bourbons who neglected the army greatly. "Napoleon had never before handled an instrument of war, which was at once so formidable, and yet so fragile," as Houssaye summarized.
Blucher's Prussian force was mainly composed of veterans, even the youngest had participated in the battles of 1813 and 1814. They were motivated by a strong spirit of revenge for their painful defeat in 1806 and being reduced to almost a second rate power by Napoleon. Just before Waterloo, at Ligny, Blucher was defeated badly by Napoleon, sustaining 20,000 casualties in an 84,000 man force. Though 8,000 of these were deserters, the rest were able to regroup and move to assist Wellington at Waterloo. Napoleon's army didn't have the morale capacity to sustain such a reverse.
So though Wellington's force had its drawbacks, so too did Napoleon's. Really it just comes down to the fact that he won at the end of the day, as defeating Napoleon, regardless of how or why, is a tremendous feat. The Archduke Charles defeated Napoleon at Aspern-Essling, but he had between 30,000 and 60,000 more men between the two days. It didn't really matter though, Napoleon hadn't lost in ten years and that was a huge blow to his myth of invulnerability. The same goes for Wellington, it only mattered that he won.