On the question of "why 12 notes", I STRONGLY recommend this video by David Bennett:

https://www.youtube.com/watch?v=lvmzgVtZtUQ

There's a really important step missing in the article which has been aluded to by a couple of comments already. It's the step between:

1. a series of notes defined by the harmonic series, that is, exact integer multiples (or ratios, if you prefer) of a base frequency, a physical phenomena found in nature

and

2. the well-tempered scales used by most western music, which adjusts the ratios to allow certain compositional "tricks" to be used without sounding dissonant.

The set of notes defined by (1) are typically referred to as "Just Intonation", and was the basis for most western music (and some non-western music) until somewhere between about 1400 and 1600 (lots of room for discussion/debate there).

The "problem" with just intonation, if indeed it is a problem, is that if you define two series of notes (call them a scale, if you like) using these integer ratios but starting from two different notes, you will trivially find cases where "the next higher E" is a different frequency. So starting from (say) A and moving by integer ratios gets you to a different (say) F than if you start from (say) B.

This means that if you are writing in a just intonation scale with (say) A as the root, you have a set of notes that are not actually the same frequencies as if your scale started on (say) B.

By itself, this is not a problem at all - there is all kinds of lovely music written through history that works just fine with notes and scales defined this way. You just stay in the same scale throughout, and there are no issues. There are even some scale changes you can make that still work, you just have to know what they are (and they depend on the root note and the set of integer ratios you're using, so it gets complicated).

But ... somewhere in the period mentioned above, a subset of western musical culture started to want to experiment with "modulation" - changing from one scale to another in the midst of piece. On continuous pitch instruments (e.g. violin, voice), this is entirely possible to do, since they can play any frequency in their range at all. However, it does require significant skill on the part of the performer, since the pitch of a (say) "F" will differ depending on the scale currently in use in the piece.

The breaking point, such as it was, came with the development of fixed pitch instruments (keyboards). These can only play the notes they are currently tuned to, and so if the (say) F in two scales is a different frequency, you cannot play in both scales without retuning - an obvious impossibility in the middle of a piece.

So, "well-tempered" tuning was developed - the ratios described in TFA. These are tweaked by relatively small amounts so that the notes are close to where Just Intonation (integer ratios) would have placed them, but not precisely the same. These small shifts mean that the (say) "F" is the same frequency whether your scale began on (say) A or B. You can now play a fixed-tuning instrument like a harpsichord or a piano, change from one scale to another, and everything remains "in tune".

Of course, to ears used to Just Intonation, "well-tempered" tuning sounds out of tune. But in the west, most people (even within our musical academies) have grown up used to the sound of well-tempered tuning, and it is Just Intonation that sounds "off".