It almost certainly dates back to the days when a victorious army would plunder the places they had recently attacked and defeated. Obviously, the soldiers would stuff their pockets, bags or whatever and then - so as not to miss anything - even their boots. Soldiers - particularly cavalrymen - in past times often wore thigh-length boots which were quite roomy! That's why we have the modern sense of "take full advantage" when we use the saying.