My question is regarding Revelation 20:5, where it says this is the first resurrection. If this is the first, then how could there be a rapture beforehand?
Three days after His crucifixion, Jesus was resurrected, the first fruits of the dead (1 Cor. 15:20). At the same time many holy people were resurrected and were seen in Jerusalem (Matt. 27:51-54).
At the rapture of the Church the dead in Christ from the Church Age will be resurrected (1 Thes. 4:16-17). And at the time of the 2nd Coming, tribulation martyrs will be resurrected (Rev. 20:4-5) along with the believing Jews from Old Testament times (Daniel 12:1-2).
All these are part of the first resurrection, which is the resurrection to everlasting life. The second resurrection takes place at the end of the Millennium and is the resurrection to shame and everlasting contempt (Daniel 12:2, Rev. 20:11-15).
It helps to think of the number of types of resurrections rather than the number of resurrection events. There are two types, called the first resurrection and the second resurrection. But as you can see several resurrection events are included in the first resurrection.