It is difficult to know when Joel lived since he does not mention any king. Therefore, opinions vary, with suggestions ranging from the 8th century to the 3rd century. But there are good arguments for him living between the falls of the Northern and Southern Kingdoms, i.e., between 722 and 586 BC, so the 6th century is a good suggestion.
Another thing that is difficult to know is whether he was talking about locusts, an invading nation, or both. Here, too, there are different opinions, but again, a good suggestion is that chapter 1 is about a locust swarm that has destroyed the crop, which had already happened in Joel’s time, and that Joel knows that this happened because they did not keep the law. It was written in the Law of Moses that this would happen if they broke the law, to make them wake up and return to God. This locust invasion is then used in chapter 2 as a warning of something even worse that may come if they do not repent: A real invasion, an attack by “a large and mighty army” (v. 2), who “never was in ancient times nor ever will be in ages to come.” Chapter 2 describes these people as invincible enemies, and it sounds like the Assyrians or the Babylonians.
In the middle of chapter 2, rescue is provided. To escape the judgment of this terrible invasion, God says that they must return wholeheartedly to him. Then he will reverse the locust calamity, give them an abundant harvest, and drive away this invading enemy.
Then we jump a little forward in time, and God says that “And afterward, I will pour out my Spirit on all people.” – not just on the kings, priests, and prophets as usual in the OT, but on everyone! Then he will also judge all peoples, and the book ends with abundant crops and water. And after that, “the Lord will dwell in Zion” (3:21, DRA), i.e., in the temple.
The verses in chapter 3 about God pouring out his Spirit are well-known since they are quoted in Acts 2, and thus were fulfilled on Pentecost. But when Peter quoted Joel in Acts 2, he also said that the day of the Lord would come immediately after the Spirit is poured out. The reason for this is that the prophets only saw one event when they saw that the Messiah would come; God did not let them see that Jesus would come twice. So, the fact that the sun will turn to darkness and the moon to blood when the day of the Lord comes does not belong to Jesus’ first coming or the day of Pentecost but is connected with Jesus’ return. Therefore, there is a jump from Pentecost in 3:2 to Jesus’ return in 3:3. And Paul quotes v. 5 in Rom 10:13 that “everyone who calls on the name of the Lord will be saved”, which therefore applies to the time between Pentecost and Jesus’ return.
The judgment on the nations in chapter 3 will then happen when Jesus comes again to judge the whole world. The book ends with a lot of water, God’s presence, and images of a good life with lots of harvests, etc. It is not unusual for the prophets to end with such a picture of lots of water. Ezekiel and Zechariah also do that, and Amos ends up with a large harvest (which, of course, needs a lot of water to grow). Jesus seems to say that he is the fulfillment of all this water that is to come when he says in John 7:37-39 that he has the living water, the Holy Spirit. This is what Joel exactly meant when he said that it would be poured out on everyone. Thus, the end of Joel becomes a picture of eternity, the Messianic age, when God lives among men again.