(Re 11:3, 4) And I will cause my two witnesses to prophesy a thousand two hundred and sixty days dressed in sackcloth. These are symbolized by the two olive trees and the two lampstands and are standing before the Lord of the earth.
Who they speak for
While Jesus was on earth, he was God's representative. In the last days his chosen ones represent him: they stand before him and announce God's coming judgments to the world. The picture comes from Zechariah 4, where the two olive trees are "the two anointed ones who are standing alongside the Lord of the whole earth." They aren't two people from the past come back. They are the seed of the woman, the remaining ones on earth that the dragon makes war on (Revelation 12:17), given power for a fixed 1,260 days.
When they appear
The Sacred Secret study on this site puts their appearance at the opening of the 1,260 days. The holy ones who have died don't exist anywhere. So when the period begins, the Sacred Secret, the Jerusalem above, gives birth to them out of non-existence as new creations, the same way it gave birth to Christ (Revelation 12:5). Those still alive on earth finish the witness, and when the full number is complete, everyone is brought forth together just before the seventh trumpet (1 Thessalonians 4:15-17).
Their death and resurrection
(Re 11:7) And when they have finished their witnessing, the wild beast that ascends out of the abyss will make war with them and conquer them and kill them.
The beast from the abyss is the eighth king, and it has ascended only once. Any reading that has the witnesses killed in 1918 and the beast ascending again in 1945 fulfills the prophecy twice, and the text won't bear that reading. After three and a half days "spirit of life from God entered into them" and they're called up to heaven (Revelation 11:11, 12).
Why they matter for the mark
Taking the mark of the beast means rejecting the testimony the two witnesses give. The Pharisees sinned against the holy spirit by refusing the one God sent, and those who take the mark do the same to the ones Christ sends. So the choice during the tribulation is stark: the witnesses' testimony on one side, the image and the mark on the other.