This article from the Summa is an interesting treatment of liturgical fasting by the Angelic Doctor, which offers some valuable insight into the Lenten fast and its purpose, i.e. a preparation for the Baptismal mystery of Easter. From ancient times the feast of Easter has been associated with the sacrament of Baptism, for our regeneration is a kind of resurrection, a new life. Traditionally, Easter Sunday was the day when the catechumens were to receive the sacrament. But even for those who have already been born into the Church, there is a spiritual renewal which may and should be undergone every year when this feast comes around. The Lenten fast is a preparation for that spiritual renewal, and proves to be intimately connected with the mystery of Baptism - a kind of purification from sin, like the great flood itself.
Here is Saint Thomas.
Article 5. Whether the times for the Church fast are fittingly ascribed?Objection 1. It would seem that the times for the Church fast are unfittingly appointed. For we read (Matthew 4) that Christ began to fast immediately after being baptized. Now we ought to imitate Christ, according to 1 Corinthians 4:16, "Be ye followers of me, as I also am of Christ." Therefore we ought to fast immediately after the Epiphany when Christ's baptism is celebrated.Objection 2. Further, it is unlawful in the New Law to observe the ceremonies of the Old Law. Now it belongs to the solemnities of the Old Law to fast in certain particular months: for it is written (Zechariah 8:19): "The fast of the fourth month and the fast of the fifth, and the fast of the seventh, and the fast of the tenth shall be to the house of Judah, joy and gladness and great solemnities." Therefore the fast of certain months, which are called Ember days, are unfittingly kept in the Church.Objection 3. Further, according to Augustine (De Consensu Evang. ii, 27), just as there is a fast "of sorrow," so is there a fast "of joy." Now it is most becoming that the faithful should rejoice spiritually in Christ's Resurrection. Therefore during the five weeks which the Church solemnizes on account of Christ's Resurrection, and on Sundays which commemorate the Resurrection, fasts ought to be appointed.
On the contrary, stands the general custom of the Church.I answer that, As stated above (1 and 3), fasting is directed to two things, the deletion of sin, and the raising of the mind to heavenly things. Wherefore fasting ought to be appointed specially for those times, when it behooves man to be cleansed from sin, and the minds of the faithful to be raised to God by devotion: and these things are particularly requisite before the feast of Easter, when sins are loosed by baptism, which is solemnly conferred on Easter-eve, on which day our Lord's burial is commemorated, because "we are buried together with Christ by baptism unto death" (Romans 6:4). Moreover at the Easter festival the mind of man ought to be devoutly raised to the glory of eternity, which Christ restored by rising from the dead, and so the Church ordered a fast to be observed immediately before the Paschal feast; and for the same reason, on the eve of the chief festivals, because it is then that one ought to make ready to keep the coming feast devoutly. Again it is the custom in the Church for Holy orders to be conferred every quarter of the year (in sign whereof our Lord fed four thousand men with seven loaves, which signify the New Testament year as Jerome says [Comment. in Marc. viii]): and then both the ordainer, and the candidates for ordination, and even the whole people, for whose good they are ordained, need to fast in order to make themselves ready for the ordination. Hence it is related (Luke 6:12) that before choosing His disciples our Lord "went out into a mountain to pray": and Ambrose [Exposit. in Luc.] commenting on these words says: "What shouldst thou do, when thou desirest to undertake some pious work, since Christ prayed before sending His apostles?"With regard to the forty day's fast, according to Gregory (Hom. xvi in Evang.) there are three reasons for the number. First, "because the power of the Decalogue is accomplished in the four books of the Holy Gospels: since forty is the product of ten multiplied by four." Or "because we are composed of four elements in this mortal body through whose lusts we transgress the Lord's commandments which are delivered to us in the Decalogue. Wherefore it is fitting we should punish that same body forty times. or, because, just as under the Law it was commanded that tithes should be paid of things, so we strive to pay God a tithe of days, for since a year is composed of three hundred and sixty-six days, by punishing ourselves for thirty-six days" (namely, the fasting days during the six weeks of Lent) "we pay God a tithe of our year." According to Augustine (De Doctr. Christ. ii, 16) a fourth reason may be added. For the Creator is the "Trinity," Father, Son, and Holy Ghost: while the number "three" refers to the invisible creature, since we are commanded to love God, with our whole heart, with our whole soul, and with our whole mind: and the number "four" refers to the visible creature, by reason of heat, cold, wet and dry. Thus the number "ten" [Ten is the sum of three, three, and four] signifies all things, and if this be multiplied by four which refers to the body whereby we make use of things, we have the number forty. Each fast of the Ember days is composed of three days, on account of the number of months in each season: or on account of the number of Holy orders which are conferred at these times.Reply to Objection 1. Christ needed not baptism for His own sake, but in order to commend baptism to us. Wherefore it was competent for Him to fast, not before, but after His baptism, in order to invite us to fast before our baptism.
Reply to Objection 2. The Church keeps the Ember fasts, neither at the very same time as the Jews, nor for the same reasons. For they fasted in July, which is the fourth month from April (which they count as the first), because it was then that Moses coming down from Mount Sinai broke the tables of the Law (Exodus 32), and that, according to Jeremiah 39:2, "the walls of the city were first broken through." On the fifth month, which we call August, they fasted because they were commanded not to go up on to the mountain, when the people had rebelled on account of the spies (Numbers 14): also in this month the temple of Jerusalem was burnt down by Nabuchodonosor (Jeremiah 52) and afterwards by Titus. On the seventh month which we call October, Godolias was slain, and the remnants of the people were dispersed (Jeremiah 51). On the tenth month, which we call January, the people who were with Ezechiel in captivity heard of the destruction of the temple (Ezekiel 4).Reply to Objection 3. The "fasting of joy" proceeds from the instigation of the Holy Ghost Who is the Spirit of liberty, wherefore this fasting should not be a matter of precept. Accordingly the fasts appointed by the commandment of the Church are rather "fasts of sorrow" which are inconsistent with days of joy. For this reason fasting is not ordered by the Church during the whole of the Paschal season, nor on Sundays: and if anyone were to fast at these times in contradiction to the custom of Christian people, which as Augustine declares (Ep. xxxvi) "is to be considered as law," or even through some erroneous opinion (thus the Manichees fast, because they deem such fasting to be of obligation)--he would not be free from sin. Nevertheless fasting considered in itself is commendable at all times; thus Jerome wrote (Ad Lucin., Ep. lxxi): "Would that we might fast always."