Matthew 21:17

And he left them, and went out of the city into Bethany; and he lodged there.

Matthew 21:17 belongs to the closing events of Christ's final visit to Jerusalem at the time of His triumphal entry and riding into the city, in the account that includes the barren fig tree. The triumphal reception foreshadowed His coming in glory, while the triumphal entry, the cleansing of the desecrated temple courts, and the judgment on the barren fig tree pointed to Jerusalem's doom. The chapter teaches that the fruitless, pretentious fig tree represents people who profess to serve God and belong to the church but bear no fruit in their lives to God's glory.

After cleansing the temple courts of their desecration and healing the sick there, which was His final appeal to Jerusalem, Jesus left the temple and the city with His disciples and went to Bethany, where He lodged. As He left He looked upon the temple and the city with sorrow and tears, which were a final appeal of love and compassion that Jerusalem rejected. After He left, when the people sought Him to make Him king, He was no longer there.

The next morning He returned from Bethany to the city, beginning the events involving the fig tree. Rejection of Christ would bring judgment on Jerusalem and, ultimately, destruction on those guilty of His death.