The reason he writes concerning this fellowship is that our joy may be full. And these things write we unto you, that your joy may be full. John realized that the world isn't capable of providing true and lasting joy for the human heart. This joy can come only through a proper relationship with the Lord Jesus. He has a deep seated joy to offer us that can't be disturbed by earthly circumstances.
Fellowship describes the situation where two or more people share things in common.
John is going to try to get across to us just what is necessary for true fellowship with other believers and with God. This then is the message which we have heard of him, and declare unto you, that God is light, and in Him is no darkness at all. John's epistles concentrate first on light, then love, followed by life. In the scriptures, light always refers to what is right. John used that illustration several times in the gospel of John.