The book was accepted into the canon at the Council of Carthage in 397 AD.
It was, at the time when the canon was being constructed, believed to be authored by the Apostle John. Anything written by one of the disciples of Jesus tends to be held sacred.
There was some opposition to its inclusion. One of the views against this was that it was one of the main books of Montanism, which was considered heretical at that the time. Gregory of Nazianzus argued against its inclusion due to the difficult in interpretation and the possibility of abuse.
However there was a precedenceprecedent of it being included in the canon that extended back to the 2nd century.
Summary
Given the tradition of it being included in the early pre-cursorsprecursors to the canon and it'sits generally accepted authorship fromby an apostle, the book was included in the canon.