I'm from the states, so I'm not so sharp on the history of various European monarchs. Having been told as a child that my ancestors emigrated from Scotland, I've always had an interest in the country. So to sum up, what led up to, and eventually caused the merger of the Kingdom of Scotland and the Kingdom of England?
The first attempt at unification was sparked by succession disputes, after Margaret of Scotland died in 1290. This lead to a series of conflicts, spanning from 1296 to 1357, known today as the Wars of Scottish Independence. Scotland retained its status as an independent nation after the end of the wars.
The claim of Mary, Queen of Scots to the English throne ended up with her losing her head (literally), however when Elizabeth I of England died, Mary's son, James VI of Scotland was proclaimed King of England and Ireland (as James I), leading to the union of the crowns (1603). Scotland still remained a sovereign state, sharing a monarch with England.
The Glorious Revolution (1688) created fertile ground for union debates and unification eventually happened in 1707, with the Acts of Union. The years prior to the Acts of Union, Scotland had faced a famine, the "ill years", and was in a poor financial state after the failure of the Darien scheme, a series of expeditions to establish a colony on the Isthmus of Panama.
To answer the question here are some extracts from specified sources:
A simple answer is because of the lines of inheritance.
In the 16th century, there was a rivalry between two queens, Mary Queen of Scots, and Queen Elizabeth I, who each wanted the throne of the other, and who were cousins.
Mary Queen of Scots fled to England after being overthrown in her own country, and was imprisoned for nearly 20 years, before being behead by Elizabeth I for plotting against her (Mary's letters to supporters were intercepted by English spies).
But Mary had married Lord Darnley, and had a son, James VI of Scotland, while Elizabeth I, the "Virgin Queen" had no children. As such, Mary's son, James VI of Scotland was next in line for the throne of England, and ruled as King James I of that country. That's because Mary's grandmother was the older sister of Henry VIII, Elizabeth I's father. (None of Henry VIII's other siblings or his children had children of their own.)
The ascension of Scotland's King James I to the throne England started the unification process, which was completed over a century later when the Scots claimants to the throne of Scotland were defeated in battle.