In many comedy series like Friends and How I Met Your Mother we hear laughter in funny scenes. Where does this sound come from? Is it a recorded sound or is it from real audiences?
It's called a "laugh track". They've been around since radio shows and they're often used to prompt the audience into finding the jokes funny.
Before radio and television, audiences experienced live comedy performances in the presence of other audience members. Radio and early television producers attempted to recreate this atmosphere by introducing the sound of laughter or other crowd reactions into the soundtrack.
Jack Dadswell (also known as the "Traveling Reporter" by Time Magazine), former owner of WWJB in Florida, created the first "laughing record".
In 1946, Jack Mullin brought a Magnetophon magnetic tape recorder back from Radio Frankfurt, along with 50 reels of tape; the recorder was one of the magnetic tape recorders that BASF and AEG had built in Germany starting in 1935. The 6.5 mm tape could record 20 minutes per reel of high-quality analog audio sound; Alexander M. Poniatoff then ordered his Ampex company to manufacture an improved version of the Magnetophon for use in radio production. Bing Crosby eventually adopted the technology to pre-record his radio show, which was scheduled for a certain time every week, to avoid having to perform the show live, as well as having to perform it a second time for West Coast audiences.
With the introduction of this recording method, it became possible to add sounds during post-production. Longtime engineer and recording pioneer Jack Mullin explained how the laugh track was invented on Crosby's show:
"The hillbilly comic Bob Burns was on the show one time, and threw a few of his then-extremely racy and off-color folksy farm stories into the show. We recorded it live, and they all got enormous laughs, which just went on and on, but we couldn't use the jokes. Today those stories would seem tame by comparison, but things were different in radio then, so scriptwriter Bill Morrow asked us to save the laughs. A couple of weeks later he had a show that wasn't very funny, and he insisted that we put in the salvaged laughs. Thus the laugh-track was born."
Amusingly, for some shows, you can find versions without the laughter track and I, at least, regularly find them less funny without. Here's an article about their effect on audience reactions.
Most modern sitcoms are shot on closed sets, without a live audience, so the laugh track is added in post. However, many shows used to be shot on open sets and much of the laughter was from actual audience reactions, though it was often enhanced/supplemented with recorded tracks.
Soon after the advent of the laugh track, Lucille Ball and Desi Arnaz devised a method of filming with a live audience using a multi-camera setup. This process was originally employed for their sitcom I Love Lucy, which used a live studio audience and no laugh track. Multi-camera shows with live audiences sometimes used recorded laughs to supplement responses. Sketch comedy and variety shows began to migrate from live broadcasting to videotape, which allowed for greater ease in editing during post-production. Editing a prerecorded live show with quadruplex videotape caused bumps and gaps on the soundtrack, Douglass was then called upon to bridge these gaps.
While Charley Douglass was the originator and had a monopoly of sorts due to his ownership of the only machine capable of adding the laugh track to the tape, he eventually lost his control as technology improved and studios were able to replicate his process:
The Douglass laugh track became a standard in mainstream television in the U.S., dominating most prime-time sitcoms from the late 1950s to the late 1970s. By the 1980s, the Douglass family was eventually outrivalled by other sound engineers who created stereophonic laugh tracks different from the original analog track. Also, many single-camera sitcoms by this time started diverting from a laugh track altogether to create a more dramatic environment.
Modern laugh tracks are recorded and banked by sound designers and they often have tons of tracks to choose from so they can be matched to the specific type of laughter reaction that the audience should have.
Regardless, there's tons more historical info about the laugh track and the use of live audiences in the Wikipedia article but this should get you started.