Although there is evidence of human habitation in Latvia much earlier, the most concrete evidence we have places human settlements in what is now Latvia starting in about 10,000 B.C.E. These people are thought to have come generally from the southwest, more specifically from Ahrensburg in Schleswig-Holstein, although it clearly wasn't called that at the time. Latvian settlement is thought to be an outpost of a larger culture from Ahrensburg that dates to the middle Stone Age. These first Latvians were the main group in the region until around 3000 B.C.E., when the ancestors of the Finns, Livs, and Estonians probably began to make their presence felt. Baltic tribes, generally considered to be the ancestors of modern Latvians, didn't enter the area until about 2000 B.C.E.
Coming generally from the south, these Baltic tribes mixed fairly indiscriminately with the natives and were eventually assimilated into the cultures already present in Latvia. Record keeping wasn't something that these Latvians were very fond of, apparently, and the first recorded reference to them we have is by the Roman historian Tacitus, who said that the Balts lived as farmers on the coast of the "amber sea" (presumably the Baltic Sea). For some reason, the Latvians and Germans, living in roughly the same area, decided at about this time to subdivide their tribes into smaller groups. As a result, new tribal groups formed in both Latvia and the region to the south, which would eventually become Prussia and Lithuania. The Latvians themselves were divided into three groups: the Latgalian, Zemgalian, and Kurzemian. There was also an active tribe of traders living to the west of the Bay of Riga. Known as the Kurshi, they enjoyed special prominence during the times of the Vikings as an intermediary trading group between Byzantium and Scandinavia and also exported amber jewelry (amber is apparently fairly common on the Baltic coast, which may explain why Tacitus said Latvia was on the amber sea).
The Latvians had a great pagan system going on (which you can read about here), and everything was going just fine in Latvia until the Pope tried to get a hand in. He sponsored a crusade to Latvia in the 13th century which was carried out with German leadership and manpower. This crusade was seen as equal before God with the better-known Crusades to the Holy Land that had been going on for a while. Predictably enough, the crusade led to war, which lasted about a hundred years. When all was said and done, the Germanic princes had subjugated Latvia and named it Livonia. That was only the dominant state in the region, though. A number of smaller city-states also sprung up, many of which were involved in the Hanseatic League once that got up and going in the 15th century. Riga, Cesis, Ventspils and Kuldiga were a few of the more prominent towns, especially in the trading for which the Hanseatic League was formed. Those merchant cities also helped make sure the German control over the region didn't go uncontested; they fought the Germans fairly regularly.
Class during this period was ethnically based, apparently. The Germans took up the higher rungs on the social ladder, becoming lords and other rulers, understandable considering the fact that they did conquer the area by force. The middle and lower classes were ethnically Latvian. This state of concurrent class and ethnic conflict is said to be the reason for Latvia's retention of ethnic identity for such a long time when their neighbors (especially the Prussians to the south) mixed freely regardless of ethnic origin and as a result eliminated both ethnic contention and seperate ethnic identities. Ethnic identity or not, though, the Latvians were beginning to grow tired of their poor conditions as well as the constant fighting between the city-states and the German state, resulting in a general call for reforms as the 15th century came to a close.
Protestantism was declared the state religion in 1554. Although it's not clear to me how, the sources connect this with an increase in Russian raiding activity. Somehow, the change to Protestantism weakened the German state militarily, although the exact mechanism is apparently left to the imagination. The end result, however, was that a number of cities in Latvia gave up their sovereignty in 1561 to the Polish-Lithuanian state in exchange for Polish-Lithuanian protection from the Russian raiders. Kurzeme and Riga did not, though, and Kurzeme established an independent duchy for itself to the west of the Daugava River, a state which lasted until 1795. In the newly annexed Polish-Lithuanian region, the new rulers abolished the Protestant state in favor of a Catholic one, but kept all of the former German ruling classes. The peasantry apparently became increasingly dependant upon the noblemen during this period.
Sweden and the Polish-Lithuanian state fought over control of the Baltics during the 17th century as Sweden attempted to exert full control over the Baltic Sea. Gustav Adolf II, king of Sweden, marched into Riga in 1621, establishing Swedish rule over much of northern section of the country (Vidzene and Riga). The Swedes were much more liberal than previous Latvian rulers, and the time they were in power is known as the "Good Swedish Times" because the Swedes enfranchised a lot of the farmers by providing them with representatives in the Swedish government and the right to petition the Swedish king. Schools were established in the countryside for peasants and the Bible was also translated into Latvian, both firsts in Latvian history.
Things were also looking good in the aforementioned independent Duchy of Kurzeme. Aristocracy still had some priveleges there, and a number of nobles used these priveleges as advantages in the marketplace. Economic improvements took place as the 1600's continued, and when Duke Jacob ruled from 1642-1682, things were great in Kurzeme. Shipbuilding and metallurgy flourished, and Kurzeme was even able to establish some overseas colonies, such as Tobago and a piece of Africa near modern Gambia.
In the Polish-Lithuanian section of Latvia, Latgale, the German aristocracy was absorbed into the aristocracy of the Polish-Lithuanians. Catholicism was also firmly established in the 17th century and lasts to this day in that area in firm contrast with its predominantly Protestant neighbors.
From 1700 to 1721, Latvia suffered greatly as the armies of Russia and Sweden duked it out over who was going to be in charge of the ice-free Baltic ports. The war, called the Nordic War, brought plague to Latvia and depopulated a few sections of the country as well. Not only that, but when Russia took northern Swedish provinces (Vidzene and Riga) in 1710, they restored the priveleges of the German aristocracy, pissing off the peasants.
When the Enlightenment hit, German thinkers like Johann Gottfried Herder and G. Merkel became quite concerned about the Latvian farmers, whose status in society was roughly the same as that of a Roman slave. The crux of the argument seems to be that feudalist societies are destined to die out, being desperately outmatched by more enlightened states. Ironically, Latvia was totally swallowed by Czarist Russia later in the 18th century as a result of two divisions of Poland. Latgale was annexed in 1772 and Kurzeme followed shortly afterward in 1795.
The 19th century was a time of intellectual ferment in Latvia. Because the Russians controlled almost all of the Baltic, the Latvians were able to attend schools in other Baltic states, most notably the University of Tartu in Finland. Latvia didn't fall behind the intellectual elites of their neighbors, either. They too were caught up in the wave of nationalism that affected a huge portion of eastern Europe. Intellectuals such as Krishjanis Valdemars, Juris Alunans, and Atis Kronvalds returned to Latvia and helped to form national awareness there, cementing a popular base for a future state. Ethnic Latvians wanted to be equal to the ethnic Germans and also wanted to be free from foreign rule, as well. As the century went on, social democrats came to have more and more influence on the country, although they didn't get their own political party until the inception of the Social Democratic Labor Party in 1904.
Of course, by that time nationalism had spread to enough of the nation that it rebelled in 1905. The idea of the revolution was to cast off Russian rule as well as German domination, but it failed miserably due to the ruthless suppression of the Russian army. Attempts at establishing a Latvian state would not succeed until after the end of World War One, when the weakening of both the defeated Germans and the newly Bolshevik Russia allowed them to declare independence on November 18, 1918. The Latvian state then had to fight off Russians, both white and red, as well as Germany, a period which lasted for two years. The first elections took place after the war in 1920 and the Constitution (Satversme) was approved two years after that. Latvia became a member of the League of Nations in 1921.
Despite the fact that no war reparations were officially given by other nations to Latvia, it burgeoned economically at first during the period between the wars. This was partially due to land reforms and consequent increased agricultural productivity and partially due to privatization of property. The country also sent a higher proportion of students to universities during this period than any other country in Europe. Standard of living rose to par with the rest of the continent, but this unfortunately did not translate to political stability. Factionalism wracked the parliament, and the worldwide depression that didn't exclude Latvia in the 1930's really didn't help things, either.
Anyway, everyone was generally pretty dissatisfied with the government, allowing Karlis Ulmanis the chance to dissolve the parliament and head a totalitarian regime. He was a nationalist leader who was popular with the military and Latvia's substantial farm population, as well. In spite of his totalitarian status, he was remarkably non-extreme. He headed Latvia on a neutral path and didn't try to cleanse any ethnicities like some other contemporary totalitarian regimes. He also apparently tried to form a trade and military union with Estonia and Lithuania, but these unfortunately failed.
The secret negotiations before World War II stipulated that Latvia belonged to Russia once Hitler and Stalin started conquering everything. Accordingly, in 1939 Russia forced Latvia to give up its political neutrality by threatening to use military force if it didn't. Soviet troops were stationed in the provinces of Liepaja and Ventspils. The government wasn't dissolved until 1940, when on July 16 a puppet government was installed by Stalin. International reception of this news was apathetic at best, so Ulmanis chose to capitulate peacefully rather than be crushed outright. Soviet troops occupied the whole of the country on June 17, 1940.
The occupation was rough. Stalin, unlike Ulmanis, was one of those extreme type dictators, and he forced the relocation of a whole bunch of Latvians to the nasty parts of the U.S.S.R. and killed at least 35,000 in the first year. Then, when Hitler betrayed Stalin, the Nazis overran Latvia. Although at first any change from the Soviets was welcome, the Nazis weren't much better. Almost all the Jews in Latvia were killed in the Salaspils concentration camp or shot in the forest of Rumbula. The whole war was no good; Latvian men were conscripted on both sides and made to fight one another in addition to the domestic terrors.
The Kurzeme region had it the worst. Russian and German forces were fighting one another in the area until the defeat of Germany. When the area fell under Russian control, a whole load of intellectuals fled west across Kurzeme. The region also hosted a resistance movement in the forests until 1957. It was supported by the west and had a strong following domestically. The annexation of Latvia by the U.S.S.R. was never officially recognized by the rest of the world, but no one said they couldn't. Hundreds of thousands of Latvians were deported to Siberia at various points after the war under Stalinist rule, and Soviet citizens from elsewhere were relocated to Latvia, reducing the ethnically Latvian population. Later, under Kruschev, a number of these people were repatriated until independence movements gained strength. This led to further deportations in 1959.
The KGB intensified activities under Brezhnev, although they ran into some trouble spying in small-town oriented Latvia. It's kind of tough, after all, to keep secrets (such as the identity of your spies) in a small town. Everyone hated the regime, but state control was high so no one voiced it. Anyway, Communism didn't work, and the economy wound up getting totally screwed up. Industrialization also destroyed a lot of cultural items, like the Staborags cliff.
People were pretty pissed off, and they expressed it through drama and art, especially after Gorbachev's reforms allowed freer speech. A number of Latvians protested in front of the Freedom Monument on August 23, 1987 for independence according to annulment of the Hitler-Stalin non-agression pact. In 1990, relatively free elections were held, as a result of which the pro-independence party, the Popular Front, gained power. Independence was declared, and the Soviets responded by sending tanks toward Riga. Pressure from the world community forced them to withdraw, but not until August of 1991, during the coup in Moscow, did Latvia officially get independence. Gunter Ulmanis was elected president by the Parliament in 1993 and again in 1996. Latvia joined the European Council in 1995.
If I've gotten anything wrong, I'd really like to know about it. Just /msg sludgeeel.