When the early developments in software were taking place (somewhere between Pythagoras and Turing) the field was seen as more of a kind of mathematics. However, as it became apparent it was useful for automated data processing for governments and organizations, companies began to develop individual and proprietary systems, starting the cycle of lock-in and repeated loss of technology investment as vendors and products changed that carried on for several decades.
The idea of FOSS as we know it now began with the development in the early 1980's of the concept of "free software" by Richard Stallman, who went on to create the GNU project and Free Software Foundation to further his vision, not to mention some pretty good software. It took several more decades, but beginning in the early 2000's it became clear to most people that the free software vision was consolidating mindshare around the world.
In a co-dependent thread, in the late 1990's Eric Raymond and others developed the term "open source" as a more business friendly term than "free software", with a more inclusive meaning than free software where licenses that were not as strict about the passing on of modifications would also quality for the term. Unfortunately, by 2007 Commercial Open Source Software had effectively co-opted the term, leading the community to develop the term FOSS to bring the original visions back together.