A Dyson sphere is a colossal spherical structure constructed around a star, completely surrounding it. The interior of the sphere would absorb the entire energy output of that star, allowing for lifeforms to live on the interior surface almost indefinitely. Such a structure was theorized by 20th century physicist Freeman Dyson in the late 1950s.
For the interior of a Dyson sphere to be habitable to most humanoid lifeforms, the radius of the sphere must be such that habitable temperatures (5 – 30 °C) are maintained. The radius would therefore depend on the size and the energy output of the star around which the sphere would be constructed; if a Dyson sphere were to be constructed around the Earth's sun, the radius would have to be approximately one astronomical unit. At such a radius, the interior surface area would be about 28 ×1016 km2, or 550 million times the entire surface area of the planet Earth. Such a surface area could easily support the lives of many quadrillions (1 ×1015) of beings.
Unsurprisingly, due to the almost immeasurable amounts of effort, resources and time required to construct such an immense structure, only one Dyson sphere has ever been discovered. This particular sphere encased a G-type star and had a diameter of 200 million kilometers, giving it an internal surface area of approximately 250 million M-class planets. As no radiant sunlight or solar wind escaped from the sphere, starships were not able to detect it until they were almost on top of it. As a result, the USS Jenolan crashed onto it in 2294 after being pulled in by the sphere's immense gravity well while en route to the Norpin colony. In 2369, the USS Enterprise-D discovered the Jenolan and investigated the sphere. The sphere was deserted because the star around which it was constructed was highly unstable. (TNG: "Relics")
Technically speaking, the episode showed a Dyson shell rather than a Dyson sphere.
Freeman Dyson himself called his theory a "joke." About "Relics", Dyson said: "Actually it was sort of fun to watch it. It's all nonsense, but it's quite a good piece of cinema."  In the same interview, he said that "Stapledon sphere" would be a more appropriate name, in honor of Olaf Stapledon, whose depiction of such an object in his 1937 novel Star Maker inspired young Dyson to look into the theory.
A Dyson shell would retain all energy produced by the star, and would somehow have to radiate much of this into space to maintain a habitable surface temperature. One possible way of conserving such vast quantities of energy without emitting any visible radiation (as seen on-screen) would be to convert all the energy to mass - essentially using a replicator-like technology to create the many, many, many planets' worth of matter necessary to construct the whole sphere. Another possible way of disposing of such vast quantities of energy without emitting any visible radiation (as seen on-screen) would be to create a colossal gravitational field. If this was the case, it would explain why the Enterprise was jolted suddenly upon leaving warp, and possibly why the Jenolan's distress call went undetected until the Enterprise passed within a very short distance.
Penny Juday gave insight in creating the model by using the technique "kitbashing". The art department produced the same structures several times and combined them on a large board. (TNG Season 2 DVD special feature "Inside Starfleet Archives - Penny Juday, Star Trek Coordinator")
In book #5 of the Double Helix series (Double or Nothing) Captains Calhoun and Picard encounter a Dyson sphere constructed by an anti-Federation alliance. Calhoun and Picard eventually succeed in thwarting the alliance and destroying the sphere.
In the Deep Space Nine Millennium book series, Chief O'Brien is briefly trapped in a Pah-wraith Hell where he is forced to wander the interior of a Dyson sphere for several millennia, unable to understand how the sphere was constructed or learn anything about its creation.
In The Starless World, Kirk and crew encounter a Dyson sphere that surrounds and is controlled by a god-like entity. The sphere has been traveling towards the galactic core for several billion years at sub-light speed and intends to enter a black hole as part of an ancient compact.