The practice is a modern custom that has been encouraged by merchandisers willing to sell “St. Joseph kits” to people anxious to buy and sell their homes, but it is thought to have religious antecedents and can be, properly understood, in line with Catholic piety.
One of the religious antecedents of which I have heard is that Blessed Andre Bessette, a Canadian Holy Cross brother, requested the land on which the Oratory of St. Joseph would later be built by burying a religious medal of the saint on the property as a means of asking Joseph to obtain the land on which the Holy Cross Brothers would then build a shrine in his honor.
This is a lovely story and is reflective of the Catholic incarnational worldview that sees prayer as physical as well as spiritual. If one were to bury a statue of St. Joseph as a physical means of asking his intercession in the buying or selling (or renting) of a home, that would be perfectly fine because the focus is prayer. Were the focus merely on performing some action one has been told will “ensure” a fruitful result, that would be superstition, which is condemned by the Catechism of the Catholic Church:
Superstition is the deviation of religious feeling and of the practices this feeling imposes. It can even affect the worship we offer the true God, e.g., when one attributes an importance in some way magical to certain practices otherwise lawful or necessary. To attribute the efficacy of prayers or of sacramental signs to their mere external performance, apart from the interior dispositions that they demand, is to fall into superstition (CCC 2111).
Of course, if one were to do this, it would be advisable not to use a statue or icon that would be damaged by the procedure. If one wanted to buy a “St. Joseph kit” and use it prayerfully rather than superstitiously, that would be fine. For more information on the Catholic understanding that grace can be offered to us through physical objects, such as sacramentals or relics, please see the article linked below.
No Bones about Dem Bones** by T. L. Frazier