Short response would be - because a Lithuanian great Duke became a Polish king, and naturally, the realm transitioned into a union gradually.
It's also a bit misleading response, because it was not as clear cut.
Most of my, admittedly, limited research in the period comes from Lithuanian high school perspective, bits and pieces of Jan Długosz translations, and encyclopedia on Vytautas the Great (A. Šapoka, Z. Ivinskis, V. Dėdinas… “Vytautas Didysis, 1350-1430.”)
The roots of the union stem from Jogaila Algirdaitis (Władysław II Jagiełło), who came to rule upon the Grand Duchy of Lithuania, a country that was pagan at the time, pressured by the Teutonic Order. Added to the Theutonic Order's pressure, there was a civil war going on with his uncle Kęstutis and cousin Vytautas.
Jogailo had even lost the rule over most of Lithuania in 1381-1382, and only afterwards the war turned to his favor. Historians point out that he was on the lookout for a possible alliance, considering to strengthen the ties with the Orthodox church and the Grand Duke of Moscow, but it didn't come to that.
Around 1384, the talks about his marriage to Jadvyga I de Anjou (Jadwiga Andegaweńska) started, presumably on Polish initiative. In 14 August 1385, he signed the Union of Krewa (Krėvos Unija / Unia w Krewie). In turn for getting a new wife, becoming a King of Poland, Jogaila got christened and promised to join Lithuania under the Polish crown.
Here, the Lithuanian historians like to point out the document being a statement of intent, and not a binding document, while others point to Union of Krewa as the true start of the union between the two countries.
Jogaila was crowned King at the beginning of 1386 - but it did not end there. Vytautas, the son of his uncle Kęstutis, was still fighting for the rulership over the Duchy of Lithuania, with the help of Teutonic Order.
The civil war finally came to an end in 1392, when Vytautas and Jogaila signed a peace treaty, making Vytautas the Grand Duke of Lithuania, and letting Jogaila remain the King of Poland. The extent to which the Grand Duchy of Lithuania was a vassal of Kingdom of Poland at the time of Vytautas reign is up for debate, as the two rulers behaved as allies, but remained largely separate.
Even when the Ostrów Agreement (1392) gave Vytautas permission to rule over the Duchy of Lithuania only until his death, the ruler kept pushing for a separate crown, wishing to become a King of Lithuania, thus annulling the intents of Krewa Union to keep Poland and Lithuania as a singular kingdom.
His intentions were in vain, as Vytautas died before getting the crown, with but a single daughter Sofija (Sophia of Lithuania), wife to the Grand Duke of Moskow, in effect returning the rule over Lithuania to Jogaila.
After that shaky start, the children of Jogaila remained to rule over Poland as a Dynasty of Kings (Jogailaičiai or Jagiellons), and most of them also kept the title of Grand Dukes of Lithuania at the same time.
This continued until Union of Lublin, in July 1, 1569, when the last of Jogaila's descendants, Žygimantas Augustas / Sigismund II Augustus / Zygmunt II August, a childless King of Poland and Grand Duke of Lithuania agreed with the lower class nobles (Szlachta) to form a complete Union, culminating in the creation of the Polish-Lithuanian Commonwealth (Abiejų Tautų Respublika / Rzeczpospolita Obojga Narodów).
In the end, your answer is in two parts - first, as we speak of Union of Krewa, the drive behind the decision was a seeking of allies and a wish to deny Teutonic Order access to Lithuania by becoming a Christian state.
The said alliance evolved at Union of Lublin, where the causes for a more complete merger were many - and different from the original intentions. In some way, this might have been caused by the strengthening of the nobility classes in Poland and some parts of Lithuania.
A good topic for further research could be the 'Szlachta' as I cannot tell much about the growth of this class of nobles in Poland, but if I am not mistaken this is roughly the relevant period.
In the end, it was Krewa Union that built the foundation, and the Liublin Union which created the Commonwealth itself.
There have been a couple relevant threads I've seen around this subreddit before: https://www.reddit.com/r/AskHistorians/comments/2fstqf/why_lithuania_once_so_big_is_such_a_small_country/ https://www.reddit.com/r/AskHistorians/comments/29n2g0/why_was_lithuania_considered_simply_a_grand/ Which both mention, in part, the formation of the Commonwealth.
EDIT: also, this: https://www.reddit.com/r/AskHistorians/comments/322rbe/how_and_why_did_lithuania_and_poland_unite_into/cq7l5az