This ballad is Child 58 of James Francis Child's collected ballads, and one of the most popular. While most musicologists seem to believe that the ballad is based on a historical event, this is disputed. In any event, there is no historical record of a Sir Patrick Spens, although some contend he was actually Sir Patrick Vans.
The most popular view is that the ballad recounts a voyage to Norway that Alexander III of Scotland dispatched to return his grand-daughter, than 7 years old, to Scotland. The girl's mother, Margaret, had died in childbirth, making the grand-daughter, the Maid of Norway, the heir to the throne. The Maid of Norway did die on the trip, but not in a shipwreck. Another view is that the ballad actually chronicles a voyage Margaret took in 1281 to marry Eric II of Norway. During the return voyage, a ship transporting many of the nobles who had accompanied Margaret to Norway drowned when that ship sank. Unfortunately, this historical incident does not otherwise really fit the ballad. A third theory maintains the ballad is based upon the combination of the two events.