Well, that is a trick question. It's not clear whether the statement in question is a definition or a theorem, since it's not at all obvious initially that it even makes sense to raise a number to a complex power.
So, if we do not yet know that we can take a number to an imaginary power (if you study complex analysis, there are other approaches), Euler's formula could be thought of as a definition of it. Of course, definitions are not written in the sky, they have to have some sort of motivation behind them. Alternatively, you could interpret the statement as being an equality of functions that are defined in terms of power series. The power series continues to make sense, even if the variable becomes complex. In that case, it's just something that you check by writing down both sides of the equation as power series and making sure that they are equal.
Knowing Euler, since he was a wiz with power series, my guess is that he probably had the power series for e^x, sin, and cos at his fingertips, and as a result of having some experience dealing with these function, as well as complex numbers, maybe he noticed the similarity of the power series of sin and cos with the power series of e^x, and then realized that if he substituted ix for x in the e^x power series, it showed exactly what the relationship was, as well as providing a concept of imaginary powers. But that is just a guess about his inspiration. Maybe it's not what he was thinking. I'm no historian.
Generally speaking, I like to not just know that subject, but know how to come up with it. To at least have the illusion that I could have invented it myself. But, it turns out, a lot of times, the process through which things were invented was convoluted and ugly, and that is why we are often never told about the history. On the other hand, I believe in this (overall good and necessary) process of polishing the math, many nice insights were lost, or are now only found in obscure historical documents. Finding these historical gems can be very difficult, so I find it preferable to try to figure out my own possible path for how someone MIGHT have thought of things, although history is one possible source to look to when that fails.
This is the way I think of it. The whole point of e^x is that it is a function that is its own derivative. If you want to define e^(ix), you want the derivative to be i e^(ix), from the chain rule.
So, the question is, what function satisfies that property--that when you take the derivative, it gets multiplied by i?
The answer is given by Euler's equation. Just check what happens when you differentiate the right hand side of the equation.
Geometrically, multiplication by i is rotation by 90 degrees in the complex plane. If you picture a particle moving around the unit circle, it's coordinates will be
cos t + i sin t
The trajectory is perpendicular to the position vector, so it's clear that the velocity vector will be rotated by 90 degrees from the position vectory, in other words, multiplied by i. So, that's the function that has the properties that we want. So, we call it e^(it).