The tradition of burying St. Joseph in the earth began hundreds of years ago during the time when St.Teresa of Avila was opening Carmelite Convents throughout Europe. Taking only the bare necessities and their statue of St. Joseph, her nuns would set out in search of land or buildings suitable for a new convent. St. Teresa of Avila always encouraged her nuns to pray to St. Joseph.
It is believed that, on one particular search, the nuns found a piece of property perfect for their needs. Having no money, the nuns immediately started to petition St. Joseph for the funds needed to buy the property. In the meantime, having no place to stay, the nuns decided to bury their statue of St. Joseph on the property so he would not get stolen or broken.
After the nuns prayed to St. Joseph, someone purchased the land and built them a convent. When it was finished, the sisters dug up the statue and built a beautiful shrine inside in honor of St. Joseph.
Read more on this at the Virtual St. Joseph Altar.