There are two ways of looking at this. One way could be to view Adam's (peace be upon him) expulsion from paradise as a punishment. How is that so? Bear in mind that Allah stated that Adam will be sent to earth (ayath 36) before Adam (peace be upon him) repented (ayath37). Being forgiven could either be in relation to a worldly punishment or an afterlife punishment or both. For example, the thief who gets his hand cut off still has to repent to Allah so that he could avoid the punishment in the afterlife. Hence, Adam's (peace be upon him) descending to earth could very well be a worldly punishment for his sin, yet he was forgiven so that he won't endure the punishment of hell in the afterlife.
A second way of looking at this matter is to not interpret Adam's (peace be upon him) expulsion from paradise as a punishment. Several Muslim scholars such as Ar-Razi, Al-Qurtubi, Al-Nisapuri and others have not understood this to imply a punishment. Rather, they see that Adam's expulsion was that of mercy and that of teaching a lesson. They argued that it was that of mercy because now with Adam going to earth he would learn to become a more responsible person and be encouraged to perform more acts of worship. That in and of itself is a great reward. It was also teaching him a lesson so that he could see and contemplate about how that one sin could drive him out of paradise, yet what would a large number of sins do? Hence, this would motivate him and us reading his story to realize the seriousness of sin and how offensive it is to Allah.
It was Allah's plan right from the beginning that Adam (peace be upon him) be stationed on earth. Allah said in Quran Surah Baqrah 2:30 "I am about to place a successive authority(Khalifa)on the earth". Notice that Allah didn't say that He would place a successive authorityin paradise, but on earth.
Allah's placing of Adam (peace be upon him) in paradise initially is a helpful reminder to all of us to remember where our final destination should be and that our enemy Satan would do all he can to keep us away from it permanently.
In conclusion, there is no difficulty in understanding how Allah ordered Adam (peace be upon him) to leave paradise because of his mistake, yet still forgave him for that sin. As Allah said: Then Adam received from his Lord [some] words, and He accepted his repentance. Indeed, it is He who is the Accepting of repentance, the Merciful. Quran Surah Baqrah 2:37