@ShadowWalker for what I can tell from this chapter, the emperor has a special power to let him see the future, but then he saw his death coming, and was unable to sleep because of it.
I think MC didn't prescribe a medicine, but instead he wrote a letter for the emperor.
All that is just my speculation of course.