Karl X Gustaf and his uncle, Gustaf II Adolph, before him had ravaged Poland several times during the 1600s. The quarrel with Poland was older still. In 1586, the Polish throne was occupied by a catholic king, Sigismund, grandson of Gustaf Wasa. Sweden had been Lutheran for many years, and when Sigismund (also occupying the swedish throne since 1592) wanted Sweden to revert to catholicism, his uncle Karl (IX) opposed him in 1598 and was crowned king of Sweden after thwarting Sigismund's plans. During the 1600s, Poland lost its Baltic possession of Livonia and for a while Elbing in West Prussia was in swedish hands. When August II, elector of Saxony, was elected king of Poland 1697, he promised to regain the lost territories.
Russia had lost Estonia and Ingria in 1583 to Sweden, and in the early
1600s had had a sizable swedish army on its
soil during a messy war of succession. When Peter I became Tzar, he endeavored to bring Russia to more modern standards, upgrading the army and building a navy in the Black Sea. Unfortunately the Ottomans controlled the Bosporus Straight (Later to be the focus of the Commonwealth and French forces at Gallipoli in 1916) and Peter's navy didn't manage to defeat the
ottomans in battle, so Russia could not trade by sea that way. Archangelsk was ice locked for many months and was of no real use for trade, either. Trade going west went through the baltic ports, levying heavy tolls on goods, and we know who owned these... Peter wanted a sea port of his own in the West and there was only one way to get it.
This was the background for the Great Northern War. In 1697, danish, saxo-polish and russian diplomats met and the result was an agreement between these nations to join efforts against Sweden.
The danes had a very good excuse, besides the old quarrels. The small
duchy of Holstein-Gottorp had traditionally been subject to danish rule,
but in the last decades of the 1600s, it had grown closer to Sweden and
the current duke was even a brother-in-law of the swedish king as well
as close friend. As Denmark tried to assert its power over Holstein-Gottorp,
Swedes aided them with skilled engineers and officers and raised fortifications around the duchy. This enraged the danish king, and he went in and razed the same. The naval powers (Britain and Netherlands) along with Hannover signed a treaty with Holstein-Gottorp, guaranteeing its autonomy. In 1699, however, the danish king thought himself to have enough backing by Saxony-Poland and Russia to go on the offensive. He also knew that the naval powers were very occupied with the old enemy of theirs, Louis XIV - Le Soleil Royale...