I understand that a complex number $n = a + bi$ is defined as having real $a,b$ with $i = \sqrt{-1}$. However what I don't understand is the why. Why was it defined this way? How do we know this will be a useful way to define them? Was this emergent from previous mathematics or a defined "workaround" to address certain problems? Like what led to someone going, "Hmm, we should define a new type of number and represent it as $a + bi$ where $i = \sqrt{-1}$!" and so on.
I have been trying to understand the basics of complex analysis but I haven't yet understood why numbers are represented this way before I can wrap my head around why all these other interesting areas of mathematics work themselves out. Like I could easily envision myself defining a specific number in some way only to find later that it was a bad definition or an incomplete or inaccurate way to describe something. What makes $a + bi$ correct and why did it come about?
Historically, complex numbers were introduced by Cardan as far back as the 16th century. While people did not really understand them at the time (much like undergrads now!), introducing this famous notation $a+b\sqrt{-1}$ served in intermediate computations for finding explicit solutions to cubic equations (with real solutions!).
So if it Cardan's intuitive idea could be made rigorous (and it can, of course), then it at least has the merit of allowing one to do computations with more general numbers than just reals, before returning to reals. This is by the way also useful for factoring polynomials like $X^4+1$ over the reals.
Of course, by now we (mathematicians, physicists, engineers...) are so used to the abstract notion of complex numbers that we think of them as just as natural as reals or integers. Also, it turns out that they have this wonderful property that every polynomial (real or complex) can be factored into a product of complex polynomials of degree one. This means that complex numbers are enough to study any polynomial with real coefficients.