From a historical and sociological perspective, this essay presents and develops the first comprehensive theory of scientific collaboration: collaborative scientific research, formally acknowledged by co-authorships of scientific papers, originated, developed, and continues to be practiced as a response to the professionalization of science. Following an overview of the origins and early history of collaboration in the 17th and 18th centuries, a study of the first professionalized scientific community, that of Napoleonic France, confirms that, as the theory predicts, collaboration is a typical research style associated with professionalization. In the early 19th century, virtually all joint research was performed by French scientists; collaborative research only appeared much later in England and Germany when they, too, underwent professionalization. That historical finding, which constitutes a puzzling anomaly for any other view of scientific teamwork, here conforms to theoretical expectation. Several other predictions of the theory are presented, to be taken-up in subsequent studies.