Why notes are grouped in the way they are, as opposed so being written as a consecutive array of notes. Wouldn't that be easier to read? What if I have a bunch of notes like these, why are they grouped in this way?
The notes are grouped so that larger units of rhythms are clearly communicated. In your example, the larger units of rhythm is the 4-4 rhythm. And this helps the musician significantly in interpreting the passage and judging upon performance of said passage whether or not they have played it well enough.
Clear communication and mnemonics are very important for musicians in learning new pieces of music quickly.
Because one needs to be able to read the beat:
Can you tell me where the third beat starts in the first example, right away - at sight? It's somewhere in that mess - it's awkward to see
and there is theory to beats such as syncopation, upbeat, downbeat, accenting, rests/silence and mood/feel and the syntax of music reflect those
They are grouped into beats.
In your example the time signature is 4/4 which means 4 beats where a quarter note equals one beat. So notes smaller than a quarter note are grouped into quarter note groups.
This visual grouping helps you place the rhythms in relation to the quarter note pulse that you are hearing and feeling.
Vocal music was traditionally beamed per-syllable, not per-beat. No longer, I'm glad to say! I have a theory that this may have contributed to vocalists' notorious tendency to sing 'note to note' rather than rhythmically :-)
Notes should be grouped to show the pulse of the music. Usually in a straightforward per-beat way. (Example A). Sometimes 'across the beat' is permissable to indicate syncopated phrasing (Example B). (And no, a bar of 12/8 plus one of 2/4 would be quite different). But you'd need a VERY good reason for example C. Because it's hard to read.