Midrash Rabbah
Kohelet Rabbah 8.5
1
שׁוֹמֵר מִצְוָה לֹא יֵדַע דָּבָר רָע, זוֹ אֶסְתֵּר, שֶׁהָיְתָה עֲסוּקָה בְּמִצְוַת בִּעוּר חָמֵץ. וְעֵת וּמִשְׁפָּט יֵדַע לֵב חָכָם, זֶה מָרְדְּכַי, דִּכְתִיב (אסתר ד, א): וּמָרְדְּכַי יָדַע אֶת כָּל אֲשֶׁר נַעֲשָׂה.
“One who follows a command will not know an evil matter, and a wise man's heart will know the time of judgment” (Ecclesiastes 8:5). “One who follows a command will not know an evil matter,” this is Esther, who was engaged in the mitzva of removing leavened bread. “And a wise man's heart will know the time of judgment,” this is Mordekhai, as it is written: “Mordekhai knew everything that had been done” (Esther 4:1).