Sommersby
(1993)

The man everyone in town knows as Jack Sommersby (Richard Gere) is actually Horace Townshend, a cowardly former schoolteacher who assumed the identity of Jack Sommersby, a dead Confederate soldier to whom to whom he bore a strong resemblance.

The real Jack Sommersby committed a murder years earlier. The authorities track down Horace Townshend, arrest him, and put him on trial for that murder. Townshend could get off scot-free if he'd just admit that he's an impostor, but he refuses to do so. In his brief time as Jack Sommersby, Townshend has earned the love of Sommersby's widow Laurel (Jodie Foster) and of his neighbors. He would rather be hanged as Jack Sommersby than go back to his true identity.

Townshend is convicted of murder and sent to the gallows, but dies happy, knowing that he is loved and that he has saved the town by introducing tobacco as a cash crop.
 

Thanks John L!