This Romany legend exists in many forms, and appears to be a genuine gypsy tale, rather than one attributed to them by outsiders.
In the version I grew up with, a gypsy smith was approached by a Roman legionnaire, and commissioned to forge twelve large nails. Used to jobs of this kind, and having no reason to question his patrons, the smith did as he was bid, only to learn that the nails were to be used to fix Christ and the robbers to their crosses.
Stricken with remorse, the gypsy handed his son three of the nails, and bid him flee with them.
When the Centurion arrived to collect, the smith said that he had only had time to complete nine, and handed these over.
The Roman was forced to make do with what he had, securing the three victims to their crosses with only three nails apiece, thus saving them much pain.
The young thief, the three nails safely hidden, passed the foot of the cross as he fled, and Jesus smiled down on him and blessed him, excusing the gypsies ever after from commiting a sin when they stole, and thus theft is not an immoral act for the Romany.
However, an angry mob, discovering that the nails that executed Jesus were gypsy work, drove the smith and his kin from their land, and they have been doomed to be chased on ever since, wandering and unable to settle until the three missing nails are discovered, and their persecution ends
In other versions, a gypsy woman stole a bag of nails from a Roman soldier, with the same effect of lessening the Christ's pain, and in still others a gypsy child (either boy or girl depending on the teller) stole a fourth golden nail which was destined to be driven through Jesus' heart, thereby saving his life, and allowing the resurrection.
All the legends have one feature in common however -- for their service to the Son of God, the gypsies are immune to damnation for the sin of theft, and can therefore steal with impunity.