Fath Ali Shah wants to gain territories near Iran that are owned by Russia, Iran loses this first war and Russia keeps their territory.
After the Russians won the first war, this treaty created peace between Russia and Iran for 13 years and confirmed the inclusion of the territories Russia had won.
Once the treaty had expired Fath Ali Shah attacked Russia again in order to regain the territories he had lost in the first war. He was not successful yet again and lost this war.
Britain prevented Iran from acquiring Herat again
Russia and Britain fight over control of Iran and its oil