Lilypond "knows" very little about the semantics of music notation. It knows the rhythmic duration of the symbols for notes and rests, and some rules for avoiding collisions between entities, and that's about it. Most other notation software that was originally designed in the 20th century is similar.
It is possible to write notation software which is based on semantics rather than the visual appearance of music notation. In that case, most "rests" don't really exist at all so far as the semantics are concerned. They are just marks made in the score to fill up the gaps between the notes, following a (rather complex) set of rules.
This has interesting (and time-saving!) consequences if you edit the music. The following example has all rests automatically (and correctly) generated:
If for some reason I decide to double the length of the first note, the entire passage is rewritten correctly with only two key strokes required, to select the first note and change its duration. The notes are split up and rebeamed as necessary, as well as rewriting the rests.
Of course you can override the default notation if you want to, but most of the time you shouldn't want to do that!
Whether or not it "shouldn't be too hard", it took a team of professional software developers, who all had more than a decade of experience working on music notation software, several years to produce "version 1.0" of this.
A hard part of the problem is actually figuring out what the "rules" should be, since there are many different conventions. In the software used to make these examples there are 20 or 30 situations with different user-selectable options - this a small sample, just for one time signature (6/8):
This sort of functionality is not likely to appear in Lilypond any time soon.