This evaluates the contents of buffer evaluate-me and prints the value of each toplevel form to the buffer output:
(eval-buffer "evaluate-me" (get-buffer-create "output"))
Do C-h f eval-buffer to see the documentation that explains why this works. The second argument to eval-buffer is named PRINTFLAG, of which the docstring says:
PRINTFLAG controls printing of output:
A value of nil means discard it; anything else is stream for print.
The slightly confusing thing about this is Emacs's unusual concept of what counts as an "output stream". Buffers, markers (locations in buffers), and the echo area can all be treated as "streams", as can any function that takes a character argument. Look up the docstrings of the print function or standard-output variable for more info.
The more general way to make things happen inside another buffer is the macro with-current-buffer. Unlike set-buffer, it takes care of restoring the original context cleanly even if errors happen in the wrapped code.
(with-current-buffer (get-buffer-create "output")
(insert "some text"))