We might guess that, like many Macedonians, Gaius might have sailed the overnight journey south to do business in the big seaport city of Corinth. After being baptized by Paul, and then acting as host to the church there, he sailed across to join Paul in Ephesus during the third missionary journey. The riot in Ephesus (Acts 19:23-41) was perhaps followed by Paul's imprisonment and being thrown to the lions (2 Timothy 4:16-17). Reading ropy, "at the decisive moment," for romy which a scribe mistakenly copied as the city of Rome (in 2 Timothy 1:17) allows us to place this event in Ephesus instead of Rome. And Onesiphorus (1 Timothy 1:16-18) and Gaius (Acts 19:29) were among the few who stood by him at that terrible time.
If Gaius stayed on in Ephesus, he would have been edged out by Diotrephes (3 John 9) who also refused to allow the apostle John to come and work there. Eventually John may have succeeded in restoring the situation, and stayed on as leader of the seven churches in Asia (Revelation 2:1-3:22) till he in turn was banished to Patmos (Revelation 1:9). This letter would therefore be written by the Apostle John secretly to Gaius to encourage the eventual silencing of Diotrephes. And it would accompany 2 John which we have suggested was the covering letter for the First Epistle which John sent for copying to the seven churches.
The above suggestions are without firm proof, and therefore only guesses. The reality may have been far more complex. But an imagined reconstruction does allow us to picture what might have happened in the city of Ephesus as Gaius stood by Paul in a very dangerous situation. And it might explain why John called him "beloved" perhaps without having ever met him, and without having been able to come in person to that church as long as Diotrephes was in control.
2 John has no doubt about the health of Gaius' soul. But he prays that in all things Gaius may be getting along well (prospering, succeeding, in good health).
3 Obviously John had been concerned that the situation in Gaius' church was out of hand, and been taken over by Diotrephes (verse 9), and other false teachers. The fact that Gaius was standing firm (walking in) in the truth (see verse 1) made John "overjoyed" (as in 2 John 4)
4 This could mean that Gaius had been one of John's converts, or a member of his flock in another place. But it seems more likely that "my children" may be metaphorical for John's hearers (as in 1 John 2:1, 12, 14, 18, 28, 3:7, 18, 2 John 4).
5 Whereas Diotrephes is refusing to welcome visiting brothers and sisters (verses 9-10), John has heard that Gaius is welcoming Christian preachers from other places (called friends in vv. 5, 10, 15).
6 Some of these have told John of what Gaius has lovingly done to help them, and John is glad Gaius is willing to provide the funds needed for them to go on to the next church.
7-8 This is evidence of the fact that travelling preachers went from church to church looking only to the Christian communities to support them. And John approves the support of such people.
9 The "something" John has written to the church seems to be the First Epistle, for which 2 John was the covering letter (see introduction to 2 John). It was meant to bypass Diotrephes who has taken over most of the authority ("likes to put himself first") and does not want John's apostolic authority to question his power. It seems likely that Diotrephes was among the "deceivers" of 2John 7 who denied that Jesus was the eternal Son of God (as in 1 John 2:22-23, 4:2-3). If that is so, this would be an early example of the taking over of ecclesiastical power by those who have another agenda.
10 The Apostle John is being kept out at present by Diotrephes, who lays false charges against the apostle. But John hopes to be able to come and correct the situation in the future. Meanwhile Diotrephes refuses to welcome any who might question his authority, and prevents those (like Gaius) who would want to welcome other Christians. Diotrephes even has the power to excommunicate some who do welcome others from the church fellowship.
11 John is afraid that Gaius might be tempted to fall in line with Diotrephes, so he warns him not to imitate the false leader's evil ways.
12 John then commends a brother named Demetrius whose commitment to "the truth" (see verse 1) is known to the wider Christian community.
13-14 As in his second letter (2 John 12), John is afraid a letter might be intercepted, and looks forward to meeting Gaius in person.
15 The "shalom" greeting of peace is used by Paul in every one of his Epistles (Romans 1:7, 15:13, 1 Corinthians 1:3. 2 Corinthians 1:2, Galatians 1:3, Ephesians 1:2, Phlippians 1:2, Colossians 1:2,1 Thessalonians 1:1, 2 Thessalonians 1:2, 1 Timothy 1:2, 2 Timothy 1:2, Titus 1:4). And John sends greetings from other Christian believers ("friends') in the location he is writing from. And he wants every believer there greeted "each by name" (presumably not Diotrephes and his supporters)