It sounds like you want to simulate an interactive terminal session, in which the user types a command, waits for a response (or, given that the target is ed, sometimes waits for a response), then types another command, etc. You could write an expect script to do this, but it may be good enough to just send a line at a time to both the terminal and the target process, with a brief pause between each line.
$ while IFS= read -r line
do
echoprintf '%s\n' "$line" >/dev/tty
echoprintf '%s\n' "$line"
sleep 0.5
done < helloworld | ed
a
hello
world
.
,n
1 hello
2 world
,s,o,O,g
,n
1 hellO
2 wOrld
Q
To better distinguish input from output, you could add color or other highlighting to the echo "$line" >/dev/tty line, or, in this particular case, enable the prompt character in ed (the P command) so that a * will show up in front of each ed command.