I think that can be summed up in two words. Treasure Island.
Before the publication of Treasure Island there was no popular connection of peg legs to pirates. Afterwards it was common.
The depiction of a sea-cook with a missing leg dates back at least as far as Thomas Rowlandson's 1799 painting HERE. The historical reality was that partially disabled seamen were sometimes given less active jobs, like being the cook, though there are records of men missing or partially missing limbs in other roles as well. Robert Louis Stevenson's exact inspiration is unclear - he may have made Long John Silver the cook because it was a good role for a one-legged character, or he may have given him a missing leg because he was the cook. Possibly, the character of a one-legged ship's cook sprang fully-formed into his mind because of familiarity with depictions like Rowlandson's.
In Charles Johnson's General History of the Pyrates (London, 1724) there is a description of a pirate with one leg in the chapter on Edward England, but that is the only reference I know of to a one-legged pirate from the 'golden age'. It is worth noting that the General History was one of the books known to have inspired Stevenson in the writing of Treasure Island, so it's also possible that Silver was partly based on that description.
Either way, the source of the stereotype is Treasure Island.