A military court in April sentenced Compaore in absentia to life imprisonment for the murder, which occurred during the coup that brought him to power. He went on to rule for 27 years before fleeing to Ivory Coast during an uprising in 2014.
Despite his conviction, Compaore returned from exile for a few days earlier this month to take part in a summit of former presidents hosted by the ruling military junta. Many Burkinabes were furious to see him return as a free man.
Compaore has always denied involvement in Sankara's murder and did not directly take responsibility in the letter, which was read out by a Burkinabe government spokesman on Tuesday.
"I apologize to the people of Burkina Faso for all the acts I may have committed during my tenure, most particularly to the family of my brother and friend Thomas Isidore Noel Sankara," the letter said.
"Faced with the dramatic and critical situation that our dear homeland is facing, we have no choice but to silence our differences in order to save our common heritage, Burkina Faso," it said.
The country is facing a worsening insurgency by Islamist militants that has displaced nearly 2 million people.
Frustration at the government's inability to quell seven years of violence helped spur a military coup in January.