Code of Canon Law (CIC) provides a brief but to-the-point explanation of why abstinence, a form of penance, is practiced: “The divine law binds all the Christian faithful to do penance each in his or her own way. In order for all to be united among themselves by some common observance of penance, however, penitential days are prescribed on which the Christian faithful devote themselves in a special way to prayer, perform works of piety and charity, and deny themselves by fulfilling their own obligations more faithfully and especially by observing fast and abstinence” (CIC 1249).
For some history on this topic see
Abstinence.