Since the end of Jagiellon dynasty around the turn of the 17th century, the new king moved to Warsaw due to Lublin Union (permanent union between Poland and Lithuania) as Warsaw was located between the capital of Poland - Cracow, and the capital of Lithuania - Vilnius. read more
My understanding is that Warsaw, a newer city, became Poland's capital in the 16th century, largely because of the Union with Lithuania (which then included part of Latvia, Belarus, and much of the Western Ukraine), and because Warsaw was at the center of what was then the combined country. read more