KABUL, Afghanistan -- U.S. Marine Sgt. William Stacey was killed earlier this year by a homemade bomb in southern Afghanistan, a tragedy for which he prepared by writing a letter to his family explaining why he was fighting that was to be read in the event of his death.

The top U.S. commander in Afghanistan, Marine Gen. John Allen, read the 23-year-old's letter during a Memorial Day service Monday in Kabul in memory of all the troops who have died in the country since the war started in 2001.

"Today we remember his life and his words, for they speak resoundingly and timelessly for our fallen brothers and sisters in arms," said Allen, who also leads the NATO coalition in Afghanistan.

Stacey was on his fourth deployment to Afghanistan when he was killed on January 31 in Helmand province. The young Marine from Redding, California, told his family that he was motivated to fight in Afghanistan to protect the country's children and provide them the opportunity to go to school and live out their dreams.

"There will be a child who will live because men left the security they enjoyed in their home to come to his," Stacey wrote in his letter. "He will have the gift of freedom which I have enjoyed for so long myself, and if my life brings the safety of a child who will one day change the world, then I know that it was all worth it."

Stacey deployed to Afghanistan with the 2nd Battalion, 4th Marines, 1st Marine Division out of Camp Pendleton, California.

At least 1,851 members of the U.S. military have died in Afghanistan as a result of the U.S.-led invasion in 2001, according to the latest Associated Press count.

Allen said that since he took over command in Afghanistan in July 2011, at least 251 American troops, 76 other NATO coalition members and 1,296 members of the Afghan security forces have been killed in the country.

Three more members of the NATO coalition were killed Monday, two in a helicopter crash in the east and one in an insurgent attack in the south, the force said.

During Monday's ceremony at NATO coalition headquarters, Allen helped lay a large wreath at the base of a pedestal holding a battlefield cross – the traditional memorial to a fallen soldier, constructed using the troop's boots, rifle, helmet and dog tags. Allen stepped back and crisply saluted as Taps played over a speaker.

Support for the Afghan war has waned in the U.S. and other countries in the coalition as casualties have mounted and progress has seemed elusive. The U.S. plans to transfer security responsibilities to Afghan forces by the middle of 2013 and withdraw most of its combat troops by the end of the following year.

Despite the human cost of the war, Allen said the soldiers who have fallen did not die in vain.

"While our brothers and sisters fell in a place far from home, far from their families, the values for which they stood and for which they lived and for which they died occupy an enduring place in our hearts," said Allen. "Those values: freedom, duty, selflessness and sacrifice."

Also on HuffPost: