What you are showing is ed being used together with an editing script.
The editing script (a series of ed commands) is being passed into ed as a here-document. A here-document is a piece of possibly multi-line text redirected into the standard input of a utility. The here-document is what's between the first and last END markers. The \ in front of the first END marker means that the document is quoted, meaning that the shell will not try to expand variables etc. in it. It could also have been written as <<'END'. In this specific instance, the \ can be removed since the editing script does not contain anything for the shell to expand.
This is a common way to use ed for simpler non-interactive editing, although ed should be used with its -s option when using it in this way.
The command is equivalent in effect to using sed with
sed '10,20/^/#/' /etc/passwd
(The ed script will make the changes in the file and then display the file in the terminal before exiting without saving the changes, which is more or less what the above sed script is doing on a line-by-line basis).
This is not a good way of editing the /etc/passwd file though (which the ed script is actually not doing, thankfully, since it doesn't save its changes). For that, tools like vipw or specific commands made for modifying this file (like useradd etc.) should be used. This is because the file, on many Unix systems, needs to be in sync with one or several other files or databases, and editing it requires updating these too (which e.g. vipw does automatically).