There is no definitive answer as to what happened to St. Joseph. The Gospels were written to teach us about Jesus Christ, not his family. The few mentions of Jesus’ family in the Gospels omit mention St. Joseph once Jesus’ public ministry begins. Tradition has therefore concluded that St. Joseph must have died before Jesus’ public ministry began. And the fact that Jesus entrusted the Blessed Mother to the Beloved Disciple seems odd unless St. Joseph was already deceased.
According to the Catholic Encyclopedia unreliable traditions reported varying scenarios regarding his death:
According to the apocryphal “Story of Joseph the Carpenter”, the holy man had reached his hundred and eleventh year when he died, on July 20 (A.D. 18 or 19). St. Epiphanius gives him ninety years of age at the time of his demise; and if we are to believe the Venerable Bede, he was buried in the Valley of Josaphat. In truth we do not know when St. Joseph died; it is most unlikely that he attained the ripe old age spoken of by the “Story of Joseph” and St. Epiphanius. The probability is that he died and was buried at Nazareth.