Sofia leaves Harpo because he starts to beat her. In another sense, she leaves him because he has been influenced by his father to feel a need to physically dominate his wife, which is at odds with his natural inclination to be loving and submissive. Even though Harpo loves Sofia, he feels emasculated by her, and becomes consumed with the idea of making her "mind," like Celie "minds" Mister.
In fact, it is Celie herself who finally tells Harpo to beat Sofia. Celie's advice comes in a moment of spite: even though she is proud that Sofia is so much more independent than she is, she also resents it. Celie projects her own suffering at the hands of Mister onto Harpo and Sofia.
This toxic masculinity is a recurring theme in the book. Sofia and Harpo get into tremendous fights over this, which Sofia usually wins because of her greater size and strength. This inversion of gender roles, in which the woman is physically superior to the man, is another reason for Harpo's dissatisfaction.
Ultimately, Sophia leaves because Harpo has lost her respect. Sophia never doubts her own rebellious nature, and for Harpo to fall under the influence of his father in this way is an unforgivable sign of weakness.