Free software is software that its users may run, study, modify and redistribute without needing permission. The definition is about rights granted by the licence, not about cost.
The Free Software Foundation, founded by Richard Stallman in 1985, defines free software by four freedoms:
A program is free software only if all four apply. Software distributed without source code fails the second freedom regardless of price, which is why "freeware" and free software are different things.
Free licences divide into two families. Permissive licences, such as the MIT and BSD licences, allow redistribution under any terms, including proprietary ones. Copyleft licences, of which the GNU General Public License is the best known, require that derivative works carry the same licence — using copyright law to compel openness rather than to restrict copying.
The practical difference shows up when a company builds a product on free code. Under a permissive licence it may keep its modifications private; under a strong copyleft licence it must publish them if it distributes the result.
Sharing source code was ordinary practice in early computing, when software was supplied with hardware and users were expected to adapt it. As software became a product sold separately in the late 1970s, source code was withheld and licences began to forbid modification.
Stallman began the GNU Project in 1983 to build a complete free operating system, and wrote the GNU General Public License in 1989. By the early 1990s GNU had produced most of a system — compiler, editor, shell, libraries — but not a working kernel. In 1991 Linus Torvalds released the Linux kernel and licensed it under the GPL; combined with the GNU tools, it completed the system.
In 1998 part of the community adopted the term open source, arguing that "free" was ambiguous and that a case emphasising development quality and cost would appeal to businesses more than one emphasising liberty. The licences the two movements accept overlap almost entirely; the disagreement is about which argument to lead with.
Free software is now infrastructure. Most web servers, nearly all supercomputers, the majority of mobile devices and the software stacks of most cloud providers run on it. Its economics are unusual: the code is a shared good that no participant owns, maintained by a mixture of paid employees, foundations and volunteers, with competitors routinely contributing to the same codebase because none of them gains by keeping a shared dependency private.
The same reasoning applied to text produces free content licences such as Creative Commons Attribution-ShareAlike, under which this encyclopedia is published. OpenWiki uses a share-alike licence for the same reason the GPL exists: to keep contributions from being enclosed.