What factors contributed to Latvia's independence and helped make it happen?
The Treaty of Brest-Litovsk of March 3rd, 1918, contributed most significantly to the formal independence of all the Baltic states.
Article III. The territories lying to the west of the line agreed upon by the contracting parties which formerly belonged to Russia, will no longer be subject to Russian sovereignty; the line agreed upon is traced on the map submitted as an essential part of this treaty of peace. The exact fixation of the line will be established by a Russo-German commission.
No obligations whatever toward Russia shall devolve upon the territories referred to, arising from the fact that they formerly belonged to Russia.
Russia refrains from all interference in the internal relations of these territories. Germany and Austria-Hungary purpose to determine the future status of these territories in agreement with their population.
However, inbetween the February and the October Revolution in Russia the Baltic states including Latvia were occupied by the imperial German forces and de facto seceded from Russia. The Provisional government couldn't take them back, and the Soviet government right after October wanted to quit the imperialistic war, as the Blosheviks had promised since it started. Therefore the Decree on Peace was issued in just 2 days after the revolution.
The Workers' and Peasants' Government, created by the revolution of October 24-25, and drawing its strength from the Soviets of Workers', Soldiers', and Peasants' Deputies, proposes to all warring peoples and their governments to begin at once negotiations leading to a just democratic peace.
...
We shall of course stand by our programme of peace without annexations and without indemnities.
...
For this reason we have included a statement to the effect that we are ready to consider any condition of peace, in fact, every proposal. Consideration, of course, does not necessarily mean acceptance.
Now, it is still debatable whether or not the circumstances and conditions of the Soviet Russia made the Treary of Brest-Litovsk the way it was inevitable, or it was more of a subjective factor, but the fact is that the Soviet government realized that the Treary was unfair and looked forward to revise it later, as it was done soon, but the main priority at the time was to quit the war. And that contributed significantly to the independence of Latvia for the time period.