What does Jesus mean when he says, “An hour is coming when all who are in the tombs will hear his voice and come out, those who have done good to the resurrection of life, and those who have done evil to the resurrection of judgment"?

John 5:28 - 29

ESV - 28 Do not marvel at this, for an hour is coming when all who are in the tombs will hear his voice
29 And come out, those who have done good to the resurrection of life, and those who have done evil to the resurrection of judgment.

In the larger passage containing the verses cited in the question, Jesus was referring both to events at the time that He was speaking, and at the time of His return in glory at the close of the present age.
At the beginning of John 5, Jesus had healed a paralyzed man (who was lying on a mat by the pool of Bethesda near the Sheep Gate in Jerusalem) by telling the man to get up, pick up the straw mat on which he had been lying, and walk. (The day on which this healing took place was the Jewish Sabbath.)
As the healed man was walking around carrying his mat, he was confronted by some of the Jewish religious authorities, who regarded his act of carrying his mat as the performance of work that was not permitted on the Sabbath, which God had designated as a day of rest. When the man said that Jesus had both healed him, and then had told him to pick up his mat, the religious authorities also accused Jesus of violating the Sabbath.
Jesus responded to their accusations by saying that, in healing the paralyzed man, He was doing the same work on the Sabbath that God (whom Jesus indicated was His Father) was doing (through acts of goodness and mercy such as making the sun to rise on both the good and the evil, or sending rain to both the just and the unjust (Matthew 5:45)).
(Later in John's gospel (John 7:21-24), Jesus referred back to this incident by pointing out that God's commandment to circumcise a male child on the eighth day of his life (Genesis 17:10; Leviticus 12:3) was carried out by the Jewish authorities, even if that day fell on the Sabbath, and then saying that He therefore also had the right to perform God's work by healing on the Sabbath.)
(This was similar to other incidents in the gospels where Jesus exposed the selective legalism, hypocrisy, and misplaced values of those who condemned Him for healing on the Sabbath by reminding them that they themselves would not hesitate to rescue a sheep that they owned if it fell into a pit on the Sabbath (Matthew 12:9-14), or to lead an ox or donkey that they owned to water for them to drink on the Sabbath (Luke 13:10-17); or by noting to them that it was always lawful to do good on the Sabbath (Mark 3:1-6).)
In addition, Jesus said that He was carrying out His Father's will by bestowing not just physical healing (as with the paralyzed man), but also spiritual healing on those who had been spiritually dead, but who placed their faith in Him and in His message, which made them pass from death to life.
Jesus then told His listeners (in the verses cited in the question) not to marvel at Him or accuse Him of blasphemy based on His claim to give eternal life, because He would provide an even greater proof of His authority when He returns at the close of the present age, when He will call all the dead to rise, and they will be resurrected from their graves to face judgment, which (as Jesus had noted in John 5:22) God the Father had fully entrusted to Jesus. As a result of this judgment, the unsaved will receive God's condemnation, while those who are redeemed through faith in Christ will live eternally in God's presence.
(Subsequently, In John 11, Jesus gave further proof of His authority and power of which He had spoken by raising Lazarus from the dead through His verbal command (John 11:43-44).)