So why isn't this done already

Mainly because although it sounds easy, in fact it's a lot less trivial than the initial thought. The simplest way of locating any data directories needed is simply to find the path of the binary and then combine that with the path "../share/program/whatever". Often, that's all it takes. It's the first bit that's the hard bit. On Linux, as long as the /proc filing system is mounted, it's very easy to locate the binary that is running. Reading /proc/pid/exe, which is a symlink to the binary location. 99% of the time, /proc will actually be mounted, but problems arise when trying to make the code portable. On other operating systems, it's not always so easy to find out this information.

If this is case, the path argv[0] must be determined to be absolute or relative. If it's absolute, that is good. Usually it isn't, and then PATH is scanned to find the binary. Needless to say, this isn't exactly fun, hence the reliance on hard coded paths.

And finally none of the above techniques works with shared libraries, which often also have data directories. Clearly then, some portable mechanism is needed for determining where the various bits of a package have been installed to.