Because it’s there and it looks like a good idea until it takes one of your fingers.
The thing is, the OP people weren't doing that at all, it was some irresponsible library maintainers. If your code does that, you have to include something like the "surgeon general's warning" everywhere: "CAREFUL: USING THIS LIBRARY MAY CAUSE TERMINAL CRASHES".
History: V7 research UNIX had "getenv()", but not "setenv()".[1] BSD Unix 4.x had "getenv()" and "setenv()"[2] Google's "AI Overview" says "The setenv() and unsetenv() functions were included in Version 7 of AT&T UNIX.", but that does not seem to be correct.
This misfeature seems to be what was once called a "Berkeleyism", a Berkeley mod to UNIX.
"setenv()" predates UNIX/Linux getting threads.
[1] http://web.cuzuco.com/~cuzuco/v7/v7vol1.pdf
[2] https://archive.org/details/44bsdprogrammers0000ucbe/page/n3...