Jesus was illustrating a point. He was also making his disciples go deep within themselves to extract his message. What he had to give them may not have been received properly without their internal desire to know and to search for the deeper meaning.
Trees represent nationalities.
Figs/fruit represent the rewards of righteousness labor.
So, a fig tree represents favorable opportunities given to particular people. These opportunities allow them to prosper and produce yet more righteous fruit.
In the account to which you refer, Jesus had just had a discussion with the older men, the chief priests and scribes. They were belittling the young boys who were shouting in the temple area acclaiming Jesus as the savior. Jesus reminded them (the older men) in no uncertain terms that the scriptures had foretold that out of the mouths of babes, praise would be bestowed. So, there is a new wind blowing, so to speak.
Jesus left them behind and went outside the city to Bethany where the next morning being hungry for fruit, he approaches a fig tree. It is full of leaves, but no fruit. (Leaves represent abundance, growth, health, and vibrancy.) So, although the tree appears healthy and has many leaves, it has produced no real fruit…Something is missing.
Jesus uses this opportunity to make a point. He withers it and takes away its future opportunity. He returns to the temple where he proceeds to give two additional illustrations appropos to this account. The final explanation is revealed in verse 43 (Matt. 21): “This is why I say to you, The kingdom of God will be taken from you and be given to a nation producing its fruits.”