From what I understand the city of Krakow has been the capital of Poland in the past such as the Polish-Lithuanian commonwealth so why is it Warsaw today?
Throughout its history, Poland had three cities acting as its capital with five others acting in this capacity for relatively short periods of time. With caveat, that in the Middle Ages, especially its early and middle part, many kingdoms, Poland included, did not have capitals in the modern sense of this word, and kings were often travelling throughout their lands, with several cities acting as the major seats of power (sedes regni pricipales). According to the 'Polish Chronicle' written in early 12th century by Gallus Anonimus, there were at least four cities acting in such capacity - Gniezno, Wrocław, Kraków and Sandomierz. This said, Gniezno is generally considered a main capital of that era, so to say, due to the fact that the first ruler of Poland accepted by the Western powers has been crowned there, and the city hosted several important political events as well as housed major relics. Thus, we can say that since the coronation of Mieszko I, Gniezno was the first capital of Poland. Its status was rather short lived. When Kazimierz I, son of Mieszko II ascended to the throne in 1034, he tried to increase royal prerogatives, what resulted with strong resistance from the nobility and the king had to leave the country. Bohemian and Moravian prince Bretislav I used the resulting interregnum and resulting upheaval (sometimes referred to as 'pagan reaction', although this even was motivated primarily by politics rather than religion) and invaded Poland, plundering several cities in Greater Poland and Silesia (including Gniezno) and annexed the aforementioned two provinces. This caused Kazimierz I to move his principal seat of power to Kraków in 1041. When the son of the Kazimierz I, Władysław I gained power after his brother was forced to leave the country in 1079, he moved the royal seat of power to Płock as this was a city he was residing in (quite possibly for some time, as the local representative of his brother in Masovia). The city also acted in this capacity during the reign of Bolesław III (Wrymouth). In 1138, on his deathbed, the latter divided the kingdom among his sons, with the caveat that the eldest descendant from the line was to reign as a principal duke (princeps) in his domain with the seat of power in Kraków. Obvious upheavals typical for the feudal fragmentation notwithstanding, Kraków remained de iure capital of Poland with the short period of 1295-1296 during the short reign of the prince of Krakow, Przemysł II, who was crowned king of Poland and moved his residence (and thus, the de facto seat of power) to Poznan in Greater Poland (not too far from Gniezno, by the way). His son, and successor, Vaclav III decided to resided in Kraków and thus this city remained the principal seat of power until mid-16th century.
Zygmunt II (Elder), the last king of the Jagiellon dynasty (1548-1572), decided to move the seat of power to Warsaw permanently. A year later, the constitution of the 1569 parliament (Sejm) designated Warsaw as the fixed place of the Sejm convocations as the city was located roughly in the centre of the newly emerged Polish-Lithuanian Commonwealth. After the death Zygmunt II, the nature of the electional monarchy and the fact that the elected kings were foreigners, caused the new custom to be largely ignored by the first kings. Henry I (de Valois) resided throughout his short reign (1573-1574) in Kraków, while his successor, Stefan Bathory (1575-1576) traveled throughout the country, most commonly attending to political matters in Grodno. The next king, Zygmunt III (Sigismund Vasa) decided that he will move the royal court and all the central offices to Warsaw, because it was much more convenient. Sejm was still convening in Warsaw, what would require frequent travels from another city and the aforementioned central location of the city also made travel to various places more convenient. Zygmunt III was also more sympathetic to the Masovian nobility that was less affluent and influential than the old noble families of Lesser Poland and were primarily Catholic, unlike the latter, who were often of Protestant or Eastern Orthodox faith. Furthermore, Masovia joined Kingdom of Poland relatively lately and thus local nobility was not too tightly connected with the Polish system of power what was generally more attractive for Lithuanian nobility finding this milieu easier to navigate. Of course, the transfer has not been finished overnight, and took almost 11 years (1596-1607). This however, did not change the traditional notion of Kraków being the capital of Polish-Lithuanian Commonwealth. Despite the royal court and the highest central offices being located in Warsaw, it was former that was generally called 'capital', with the latter being merely 'a residence of His Majesty'. It should be also noted that although Zygmunt III and majority of the subsequent kings largely resided in Warsaw, the coronation ceremony was traditionally conducted in Kraków. Of note is also the fact, that during the reign of the Saxon princes from the Wettin dynasty, August II (1697-1704 and 1709-1733) and August III (1733-1763), Warsaw remained the political centre of the country, although the kings resided in Dresden, their traditional Saxon seat of power.
Then, due to the political actions taken by the neighbours, Poland gradually loses its territory and finally ceases to exist as an independent entity in 1795. Warsaw, initially reduced by Prussian government to a provincial city, it became the capital of the French-controlled puppet state of Duchy of Warsaw in 1807. The city retained its status in 1815, after proclamation of the Kingdom of Poland, another puppet state, this time controlled by Russian Empire. Although the 19th and the beginning of 20th century was rather tumultuous in that area, Warsaw was able to expand, develop and modernize. During the Great War, with the weakening of the Russian Empire, on the 12th September 1917, German and Austro-Hungarian governments proclaimed the Regency Council of the Kingdom of Poland, a ruling body residing in Warsaw that was to govern the state under the supervision of the two aforementioned occupants. The defeat of the Central Powers, however, caused the Council to proclaim Polish independence on 7th October 1918. A month later, on 11th November, the Council transfers the power over the military matters to Józef Piłsudski and three days later, it dissolves itself, transferring remaining prerogatives to him. Subsequent governments were formed and located in Warsaw, making it de facto capital of the re-emerging Poland and this position was not contested during the interwar period, cementing the position of the city as the capital. Following the German occupation, the Soviet army moved into the territory of Poland. The Communist government backed by USSR then formed and resided in city of Lublin since June 1944. It was initially decided that the capital will be established in the large, heavily industrialised and relatively well-preserved Łódź (with Kraków and Poznań being close contenders) due to tremendous damage and death toll incurred both during and after Warsaw Uprising in 1944 as well as during the battles in and around Warsaw in January 1945 (this was the closest case in modern Europe to any major city being deliberately razed). Quick reconstruction effort and the fact that Warsaw was a large, modern city located roughly in the centre of the country, in December of 1944 the new government decided to make Warsaw the state capital. This provision became official after the proclamation of the constitution of the People's Republic of Poland in 1952. And so it remains.