He rejoiced because “brethren came and bore witness” that Gaius was living consistently with the truth. Their report confirmed that Gaius was “walking in truth” (3 John 1:3).
In 3 John 1:2–4, the elder addresses a loved believer with a prayer for outward well-being that matches the health of his inner life. He explains why he prays and writes this way: visiting believers have reported that this person is living consistently with the truth. These verses sit at the start of the letter’s personal encouragement. After naming the recipient as “beloved” (verse 2), the elder moves quickly to two themes that will shape the rest of the message: concern for the recipient’s whole life and strong approval of faithful conduct.
These verses combine a personal prayer for well-being with a report of moral and spiritual reliability. The elder prays that the recipient would “prosper in all things” and have bodily health, and he frames that wish by pointing to the recipient’s already-thriving inner life (“even as your soul prospers”).
A careful answer keeps the immediate passage, the book's argument, and the whole-Bible storyline together, so the question is answered in context instead of as a detached idea.
Start with 3 John 1:3, then read the surrounding section so the answer stays connected to the passage's flow.
3For I rejoiced greatly, when brothers came and testified about your truth, even as you walk in truth.