This is one of those phrases for which it isn't difficult to come across a popular explanation. In this case the tale that is told is that portrait painters used to charge more for larger paintings and that a head and shoulders painting was the cheapest option, followed in price by one which included arms and finally the top of the range 'legs and all' portrait. As so often with popular etymologies, there's no truth in that story. Painters certainly did charge more for large pictures, but there's no evidence to suggest they did so by limb count. In any case the phrase is much more recent than the painting origin would suggest.
It is in fact an American phrase, coined sometime after WWII. The earliest citation I can find is from The Long Beach Independent, December 1949:
Food Editor Beulah Karney has more than 10 ideas for the homemaker who wants to say "Merry Christmas" and not have it cost her an arm and a leg.
'Arm' and 'leg' are used as examples of items that no one would consider selling other than at an enormous price. It is a grim reality that, around that time, there are many US newspaper reports of servicemen who lost an arm and a leg in the recent war. It is quite likely, although difficult to prove conclusively at this remove, that the phrase originated in reference to the high cost paid by those who suffered such amputations.