Fasting is a sacrifice, or offering to God. A sacrifice needs direction. When Moses was teaching Israel about offering in the temple, he was specific on the purpose of each and every ritual. There were peace offerings, to bring peace upon them; sin offering when they wanted forgiveness, thanksgiving offering and so forth. The name of the offering is according to the purpose for which it is given.
When one fasts, one denies themselves something, and that state of denial or abstention becomes the offering. Nazarites (like John the Baptist) set themselves apart and anointed for their assignment by denying themselves certain kinds of foods. So did Prophet Daniel, when praying for Israel, when He encountered the ArchAngel of God in response.
This abstention becomes the basis upon which one speaks into the spiritual world, commands and gets the attention of the spiritual powers that be. It is a sacrifice, and sacrifice is a prerequisite of gaining contact with the spiritual. For Christ to grant us audience with the father, He offered a sacrifice: Himself. I don't need to get into a demonstration of how an offering of the body of the son of God was the epitome of sacrifices. There is no greater sacrifice in terms of the Spiritual Powers commanded by that one sacrifice. Let me leave it at that for now.