Wikipedia explains it fairly simple: Shebang (unix)
Under Unix-like operating systems, when a script with a shebang is run
as a program, the program loader parses the rest of the script's
initial line as an interpreter directive; the specified interpreter
program is run instead, passing to it as an argument the path that was
initially used when attempting to run the script.[11] For example, if
a script is named with the path "path/to/script", and it starts with
the following line:
#!/bin/sh
then the program loader is instructed to run the program "/bin/sh"
instead (usually this is the Bourne shell or a compatible shell),
passing "path/to/script" as the first argument.
The shebang line is usually ignored by the interpreter because the "#"
character is a comment marker in many scripting languages; some
language interpreters that do not use the hash mark to begin comments
(such as Scheme) still may ignore the shebang line in recognition of
its purpose.[12]