Why Eliyohu HaNovi Comes First
Teshuvah
The pasuk in Trei Asar at the end of Malachi (3:23) says, "Behold, I am sending you Eliyohu HaNovi before the coming of the great and awesome day of Hashem." Rav Gedalya explains that this opens the meaning of the teaching of Chazal that the son of Dovid will come only to a generation that is kulo chayav or kulo zakai, entirely liable or entirely meritorious. A generation of the entirely liable is no obstacle, because Moshiach will find merit in everyone, and they will all do teshuvah and become meritorious. The only difficulty is the baalei machlokes, the masters of strife. If Moshiach judges one side favorably, the other side is by default guilty, and the reverse is equally true. Therefore Hashem must first send Eliyohu HaNovi to make peace in the world and end all quarrels. Only then can Moshiach be melamed zechus on everyone, and the entire world will be meritorious.
Source: Teshuos Chen, p. 114; Mishnah Eduyos 8:7