The barrier was formed over 500,000 years ago by the Q Continuum as a means of containing the omnipotent being, 0, in the void between the Milky Way Galaxy and the Andromeda Galaxy, and thus protecting the Milky Way from his evil influence. (TNG novel: The Q Continuum: Q-Strike).
Following a battle with Trelane in 2370, Q was sent back to the initial creation of the barrier, and was turned into a non-corporeal entity by Trelane. Being in a deeply disorientated state, Q became trapped inside the barrier until the 23rd century. (TNG novel: Q-Squared).
In December 2069, the Earth vessel SS Valiant was swept into the barrier after encountering a magnetic storm. Contact with the barrier leaves six crewmembers dead and chief engineer, Geirrod Agnarsson, was transformed into a psionic super-human after a disorientated Q possessed him. After Agnarsson killed several security guards, Captain Carlos Tarasco had no choice but to order the destruction of his own ship, after all crew had left via escape pods. Unfortunately, only 12 crew managed to survive the explosion and they soon began to develop psionic abilities due to their close proximity to the barrier. (TNG novels: The Valiant and Q-Squared; and TOS episode: "Where No Man Has Gone Before").
In 2265, Admiral Saylor of Starbase 33 ordered the USS Enterprise to explore the edge of the galaxy, and even probe beyond the barrier. However, upon the Enterprise's arrival at the barrier, 9 crewmembers were killed and two other began to change into super-human beings, as Q once again tried to reach out to their minds. (TOS episode: "Where No Man Has Gone Before" and TNG novel: Q-Squared).