The Gemara in Megillah 17b lays out the reasons for the order of the middle blessings. Some are based on verses, some on number associations, and some on proximity to other blessings. A summary:
The blessing for understanding is after the blessing of G-d's sanctity based on the verse והקדישו את קדוש יעקב ואת אלהי ישראל יעריצו (sanctity) being juxtoposed with וידעו תועי רוח בינה (understanding).
The blessing for repentance is based on the verse ולבבו יבין ושב ורפא לו (understanding followed by repentance).
The blessing for forgiveness follows repentance based on the verse וישוב אל ה' וירחמהו ואל אלהינו כי ירבה לסלוח (repentance followed by forgiveness).
The blessing for redemption follows that of forgiveness in order that redemption be the 7th blessing, as redemption will begin in the 7th year (of a shemitta cycle).
The blessing for healing follows in order that it be 8th, as bris mila, which requires healing, is on the 8th day.
The blessing for sustenance follows in order that it be 9th, as it corresponds to King David's prayer to foil the attempts of those who inflate prices in the markets, which King David did in the 9th chapter of Tehillim.
The blessing for ingathering the exiles follows that of sustenance as per the verse ואתם הרי ישראל ענפכם תתנו ופריכם תשאו לעמי ישראל כי קרבו לבוא.
The blessing for justice follows, as once the exiles are gathered in, justice will be reinstated, as per the juxtaposition of the verses אשיבה ידי עליך ואצרוף כבור סיגיך and ואשיבה שופטיך כבראשונה.
The blessing for the end of evil follows, as once justice is reinstated, evildoers will cease, as the verse two after the above verses is ושבר פושעים וחטאים יחדיו.
The blessing for the righteous follows, as once evil is vanquished, the righteous will be uplifted, based on the verse וכל קרני רשעים אגדע תרוממנה קרנות צדיק.
This will center around Yerushalayim, based on the verse שאלו שלום ירושלם ישליו אוהביך, and therefore the blessing for rebuilding Yerushalayim follows.
The blessing for the emergence of Moshiach follows, as after Yerushalayim is reestablished, Moshiach will come, as the verse says אחר ישובו בני ישראל ובקשו את ה' אלהיהם ואת דוד מלכם.
Once Moshiach comes, prayer will be heard, as the verse says והביאותים אל הר קדשי ושמחתים בבית תפלתי, and therefore the blessing for listening to prayer follows.
That takes us through the requests.
Some Rishonim give other explanations for some of the blessings. The Seder HaYom, for example, explains that redemption precedes health, and health precedes sustenance, as that is the order of prevalence of the needs - one cannot be concerned about the relatively long-term concern of their health when they are in imminent danger, and one cannot be concerned about their livelihood when their very life is not on certain footing.