Joseph died many years before Mary died, and before Jesus himself died. This, I believe, is because he was much older than Mary and simply died of old age. If Joseph had been aged 45 to 50 when he married Mary who was about 30, then he would be aged 77 to 82 when he died.
From Joseph’s point of view, he had previously had a normal marriage with plenty of children. It may have been a great relief to find a second wife willing to look after them. Mary seems to have spent her time going round with these sons when Joseph was no longer on the scene.
Mary and Joseph lived as a family – but in Orthodox Jewish households husband and wife do not sleep in the same bed, they have separate beds in different rooms. They are only permitted to have union on certain days of the woman’s cycle. It is Catholic belief that Mary and Joseph had no union, and Mary remained ‘ever virgin’.
From the recounting of Jesus’ life story, we see the threat to his life right from birth. Joseph played the role of protecting Mary and the child, and taking them first to Egypt and then up to Galilee for this reason.