When it comes to the gift of the Holy Spirit, we must recall that God is extremely eager to impart the gift of the Holy Spirit, but not all are prepared to receive such a wondrous gift.
Luke 11:11-13 - What father among you, if his son asks for a fish,d
will give him a snake instead? Or if he asks for an egg, will give him
a scorpion? So if you who are evil know how to give good gifts to your
children, how much more will your Father in heaven give the Holy
Spirit to those who ask Him!”
In Luke 4, Jesus (who was perfect and sinless, Heb 7:25-27) set us an example of being prepared to receive heaven's gifts. It is God who decides these gifts via the Holy Spirit (1 Cor 12 repeatedly). That is, we humans do NOT decide to get something from heaven by doing some act of pennance or other good work - God decides alone.
At the same time, God does not impart gifts to those unprepared to receive them, especially the supreme gift of the Holy Spirit. Jesus fasted for 40 days - a period symbolizing trial followed by victory (see appendix below) so that He was prepared to receive the gift He knew He would need for His ministry.
CONCLUSION
Thus, while it is God alone who gives the Spirit and the associated power of the Christian life, it is our decision about whether we are prepared to receive that gift at all and the extent to which we are willing to receive, and be used by, that precious gift!
Jesus' 40 days of preparation (Luke 4) showed how much, even the perfect Son of God was prepared to do to get "in tune" with God's wishes for His mission and understand how He was to serve. A salutary, exemplary lesson indeed.
APPENDIX - 40 day significance in the Bible
There is little question that a number of significant events occurred over a period of "forty days" such as:
- Gen 7:4, 12, 17 - forty days of rain at Noah's flood
- Gen 8:6 - forty days before Noah open the window of the Ark
- Gen 50:3 - forty days to embalm the body of Joseph
- Ex 24:18, 34:28, Deut 9:11, 25, 18, 10:10 - Moses was in the mountain forty days
- Num 13:25, 14:34 - the spies explored the promised land forty days
- 1 Sam 17:16 - forty days Goliath defied Israel
- 1 Kings 19:8 - Elijah traveled forty days into the desert
- Eze 4:6 - Ezekiel had to lie on one side forty days
- Jonah 3:4 - Jonah predicted the destruction of Nineveh in forty days
- Matt 4:1, Mark 1:13, Luke 4:1, 2 - Jesus was in the Desert fasting for forty days
- Acts 1:3 - Jesus appeared to His disciples after the resurrection over a forty day period
In some of these cases, these forty day periods corresponded to forty year periods as well.
All that can be said about this repeated use of the "forty-day" period is its clear significance - any such period occurs at a time of great trial followed by victory. Indeed, Ellicott suggests this in his comments on Gen 7:4 -
(4) Forty days.—Henceforward forty became the sacred number of
trial and patience, and, besides the obvious places in the Old
Testament, it was the duration both of our Lord’s fast in the
wilderness and of His sojourn on earth after the Resurrection.