Sails have existed for pretty much as long as we've had boats. Our earliest evidence of sails came from an archaeological dig in Kuwait, dating back to 55oo BC, which, for context, was roughly coincident with figuring out agriculture, and predating "history" by quite a margin. More substantial historical evidence comes from 4th Millennium BC in Egypt, where small boats would travel up and down the Nile, independent of the current.
Not much really changed after these single, square rigged boats up to the invention of the lateen, or triangular, sail sometime between 2000 and 500 BC by Arab sailors. Lateens were interesting because, as triangular sails, they provided much greater maneuverability and power, at the expense of controllability. This meant that lateens were ideal for calmer locations such as the Mediterranean or Arabian seas.
They fairly clearly evolved directly from square sails. Square sails provide thrust well only when the wind is directly to the rear. As such, when attempting to go at any angle to the wind, the simplest method is to angle the sails such that they remain square to the wind, and use rudders to change the course of the boat to where you want it. Clearly, this does not work well when attempting to travel perpendicularly to the wind. In that circumstance, reduced thrust may be gained by angling the sail partially into the wind. In order to retain tension, however, the boom must be angled down into the wind. This results roughly in a trapezoidal shape, as seen today in the lugsail. Simply extending this principle and removing the luff edge entirely, one is left with a triangular sail acting by vortex driven pressure differential allowing travel well into the wind.
For the next three thousand years, the single sailed ship with sail shape dependent on need (square for downwind travel or rough conditions and lateen for calm, upwind conditions) ruled. Ships were small and generally restricted to local, coastal travel, and tended to be difficult to run. The cog was an English invention that rather shook things up. A ship that could be crewed with an eighth of older styles, and carry twenty times the cargo, it provided the basis for the entire maritime revolution from the 13th to 18th centuries.
The subsequent developments are classic of increased understanding and money. The English wealth founded in the cog allowed for significant upgrades, most significantly in the final fusion of square and lateen sail in the full-rigger. These ships were primarily square riggers, with the addition of lateen derivatives such as jibs, spankers, and staysails. The net result of these developments were large ships that could carry anything and go anywhere.
The thing that made the wide-spread shipping and colonialism that has defined our modern age possible was of course, ships. Ships drove international trade, colonial expansion (both for the purposes of finding new markets and building more ships) and created the possibility of non-sustenance level agriculture. Sailing was primarily a yeoman's field, which increased their powers and wealth, eventually leading to the creation of the House of Commons, and providing some basis for American government. These yeomen were the first examples of a middle class. These ships in short provided the impetus for the creation of the modern world.
I had some fun writing this. It's a condensed and simplified version of a paper I wrote, but there are lots of other tidbits floating around in this brain. Let me know in comments if you liked this. I may keep doing it. I may even go over this again when it's not 12:30 in the morning.