Before her husband died, Judge Douglass (involved in court) was "rough" with Injun Joe, and arrested Injun Joe and humiliated him. Therefore, Injun Joe wanted to slit the Widow's face to make her ugly and suffer, as revenge.
Injun Joe murdered Dr. Robinson because 5 years before that night when Injun Joe came to Dr. Robinsons' house begging for food and Robinson wouldn't give him any. Then Robinson's dad had Injun Joe thrown in jail as a vagrant.
Mark Twain wants us to feel empathy for Injun Joe. This is demonstrated when he states that the town felt bad for Injun Joe and forgave him for his wrongs at his funeral especially after his terrible death.