During the Great Northern War, when Sweden invaded Russia, IIRC, their objective was to take Moscow. However, in July 1709, they wound find themselves defeated at Poltava. Poltava is roughly 900km south of Moscow, so how did they end up there?
While Russia was, arguably, the most dangerous enemy Sweden faced during the Great Northern War, they were not the only. Charles basically zerg-rushed Denmark-Norway and knocked them out of the war very soon after the war had started. Then he had to go Swedish Estonia where he defeated the Russians at Narva. From there, he could have moved into Russia toward Moscow, but down south Sweden still had to contend with the Polish-Lithuanian Commonwealth, and their king (August the Strong), who was also Elector of Saxony, which meant that Saxony, too, was at war with Sweden.
The road toward Poltava began in 1707. Denmark-Norway were still at peace with Sweden, Poland Lithuania was ruled by a Swedish puppet king, and Swedish troops sat in occupied Saxony. (As a side-note, while in Saxony, Altranstadt near Leipzig to be more exact, Charles had a meeting with John Churchill, 1st Duke of Marlborough. This was during the time when large parts of Europe banded together to defeat Louis XIV, and the British wanted to see if Charles could be convinced to join the anti-French coalition)
In September of 1707, Charles left occupied Saxony accompanied by an army of 43 000. Besides this army, Count Lewenhaupt, one of his best generals, waited for him in Poland with another 20 000 men, and another 15 000 troops were stationed back in Sweden and Finland.
At this time, the Russian Czar Peter the Great was in Lithuania trying to revive the party of former Polish king, August the Strong, who had been ousted in favor of Stanisław I Leszczyński under the pressure of Charles and his armies. The Czar had ordered his troops to retreat at the first sign of Charles following them, and the Russians were not late to oblige his command.
During the time Charles was in Saxony, the Russians had advanced all the way to Lemberg, in southern Poland, and now Peter the Great was in Grodno in Lithuania. Charles left Poland in Stanislaus' hands, who was given 10 000 Swedish and Polish forces to secure his throne. In January 1708, Charles marched on Grodno through the ice and snow. He had already crossed the river Nemen, situated close to Grodno, before the Czar was informed of the Swedish closing in.
After capturing Grodno from the fleeing Russians, all Russian troops in Lithuania withdrew to the voivodeship Minski, close to the Russian border. The Swedish followed them, and both the fleeing Russians and the pursuing Swedish marched day and night, through the winter hardships. From Grodno all the way to Dniepr, the area is filled with marshes and wilderness, and there were little supplies to be found anywhere.
On June 25, 1708, Charles and his forces found themselves in front of the river Berezina, right across from Boryslav, in modern Ukraine. In this area, the Czar had gathered a large amount of forces, with strong fortifications to protect them. Charles deployed a few of his regiments by the beach of Berezina, as if he would cross there, right in front of his enemies eyes, and then he took the rest of his forces south where the Swedish built a bridge, and fought back 3000 Russians attempting to stop them. The Russians did not sit around and wait for what would come however, and they broke up and fell back towards Dniepr, while destroying the roads and everything else they came across.
On his way to Dniepr, Charles encountered a force of 20 000 Russians who had entrenched themselves at a place called Holofsin, situated behind a swamp. The only way to get there was to cross a river. Charles took his Life Guard On Foot and got into the waters, passing the swamp and the river, and while he moved forward, he gave orders to his cavalry to move around the swamp and attack the Russian flank.
The Russians were surprised to find that apparently, there were no places safe enough to protect them from the Swedish, who attacked them from two sides at the same time. This battle was commemorated by the Swedish with a medal, that said: "Silvae, paludes, aggeres, hostes victi" (Fortifications, marshes, and enemies overcome).
The Russians were driven back from Poland and into their own land from every direction, and the Czar were seriously thinking about peace with Sweden. Charles, however answered the peace requests by saying that the Czar could have his negotiations with Charles in Moscow, a bold statement telling the Czar that peace was out of the question until Russia was completely subdued. Peter answered thus; "My brother Charles thinks himself an Alexander (the Great). But I flatter myself with, that in me, he shall find no Darius (III)".
Following the Dniepr north of Mohilev, you find the province of Smolensk, and through Smolensk goes the road between Moscow and Poland, and this is where the Russians and their Czar fled, with the Swedish right behind them. Over and over again, the Swedish engaged their enemies in combat, and even though the Swedish were often the victorious ones in these small skirmishes, they drained them of troops and energy.
The way towards Moscow was now open to Charles XII, but instead of awaiting the arrival of Lewenhaupt with 15 000 reinforcements, Charles took his army and turned east into Ukraine.
In Ukraine, Charles met with a man named Ivan Mazepa, who originally was a Polish noble, but who had been appointed the ruler of Ukraine by the Czar.
Mazepa, fearing Peter, sought to make a deal with Charles, to speed up the fall of the Czar. He promised Charles 30 000 Cossack soldiers along with supplies, and so the Swedish decided to spend the winter in Ukraine, and then march into Russia. When they finally arrived at the shores of the river Desna, they did not find Mazepa there, but instead a Russian army awaited them. Charles decided to cross the river and attack them, and the Russians consisted of 8000 men, which proved to not be enough to stop the Swedish.
When they finally met Mazepa, he came to them, not as a powerful ally, but more as a person in exile. He had only managed to get away with around 6000 men and some gold and silver. Count Lewenhaupt, along with his 15 000 reinforcements, were stopped at the village of Ljesna, where he found himself against a Russian army of 40 000 men, commanded by Peter himself.
Lewenhaupt eventually arrived with his men, but without supplies that were so badly needed and a lot less troops than originally. During the winter in the beginning of 1709, Charles decided to take his army and march into Russia, despite this winter being one of the coldest in memory. During these marshes, they were constantly attacked by small groups of Russians, and in April, the Swedish had only 18 000 men left, and they were in bad shape.
Charles managed to recruit some mercenaries on the way, and when he arrived at Poltava, which was a city converted to a supply magazine by Peter, he commanded 30 000 men, but the Czar was fast approaching, with a huge army.
The battle itself I presume you know about, so I hope what I have written is what you wanted to know, otherwise just leave a comment if you want more information.