From “The Institutes of the Christian Religion”
15. The purpose of fasting
A holy and lawful fast has three ends in view. We use it either to mortify and subdue the flesh, that it may not wanton, or to prepare the better for prayer and holy meditation; or to give evidence of humbling ourselves before God, when we would confess our guilt before him.
The first end is not very often regarded in public fasting, because all have not the same bodily constitution, nor the same state of health, and hence it is more applicable to private fasting.
The second end is common to both, for this preparation for prayer is requisite for the whole Church, as well as for each individual member.
The same thing may be said of the third. For it sometimes happens that God smites a nation with war or pestilence, or some kind of calamity. In this common chastisement it behaves the whole people to plead guilty, and confess their guilt. Should the hand of the Lord strike any one in private, then the same thing is to be done by himself alone, or by his family. The thing, indeed, is properly a feeling of the mind. But when the mind is affected as it ought, it cannot but give vent to itself in external manifestation, especially when it tends to the common edification, that all, by openly confessing their sin, may render praise to the divine justice, and by their example mutually encourage each other.