See an old mail from Dennis Ritchie introducing the new feature, quoted in 4.0 BSD /usr/src/sys/newsys/sys1.c.

The path component newsys was an option.

It is also mentioned as in /usr/src/sys/sys/TODO (that is, in the regular path),

6. Exec fixes Implement dmr's #! feature; pass string arguments through faster.

So this #! mechanism origins from Bell Labs, between Version 7 and Version 8,

and was then available on 4.0BSD (~10/'80), although not activated per default.

Two important differences to current implementations are:

The length of the line was limited to 16 (Research Unix) or 32 (BSD) bytes.

"Arguments" were not delivered.

It was then implemented by default on 4.2BSD (~09/'83), /usr/src/sys/sys/kern_exec.c by Robert Elz.

This implementation delivered all #! arguments as a single one.

Less than a year after 4.0BSD, but more than two years before 4.2 BSD, #! was also added to 2.8BSD (~07/'81), but not active by default.

2.x BSD is a different development line, independent from 4 BSD. It's a 7th edition (V7) kernel with fixes activated by macros.

The macro for the #! code is not present in a makefile, so you had to activate it yourself. The code wording is slightly different from 4 BSD.

On 2.8 BSD, #! seems to come from the U.S. Geological Survey in Menlo Park, not from Berkeley.

(Thanks to Gunnar Ritter for pointing out the origins in 4.0 and 4.2BSD in de.comp.os.unix.shell, to Jeremy C. Reed for mentioning Robert Elz, and to Richard Kettlewell for spotting 2.8BSD on TUHS mailing list.)

In 4.3BSD Net/2 the code was removed due to the license war and had to be reimplemented for the descendants (e.g., NetBSD, 386BSD, BSDI).

In Version 8 (aka 8th edition), #! is implemented in /usr/sys/sys/sys1.c and documented in exec(2) .

Among the public releases from Bell Labs, #! was not added until SVR4 ('88) according to a TUHS list discussion. System III and SVR1 definitely had not implemented it, yet.