One reason we fast is to demonstrate humility before the sovereign Creator of the universe. God responds when we diligently and wholeheartedly seek Him (2 Chronicles 7:14).
Sometimes this involves confession and repentance from sin. This was the case of the Ninevites when Jonah reluctantly told them God was going to bring judgment upon them (Jonah 3:5,10), 50 they called a fast and repented of their sin. Fasting demonstrates humility by acknowledging our dependence on God. In Psalm 35, David laments his enemies’ harsh treatment of him in contrast to how he cared for them when they were ill. He humbled his soul by fasting and praying for their recovery (Psalm 35:13).