How can I use AppleScript to type text into a new window?
Quotes that are meant to be literal need to be escaped with a backslash and instead of using keystroke, use the following example to create a new AppleScript document containing the wanted code:

tell application "AppleScript Editor"
    set text of (make new document) to "tell application \"System Events\"\n\tkeystroke \"n\" using command down\nend tell"
end tell


Copy and paste the code example above into a new AppleScript document and press the Compile button.  It will then look like:

tell application "AppleScript Editor"
    set text of (make new document) to "tell application \"System Events\"
    keystroke \"n\" using command down
end tell"
end tell


Then press the Run button and it will create a new AppleScript document containing the following:

tell application "System Events"
    keystroke "n" using command down
end tell


Which if you then press the Run button of this new document, it creates a new blank AppleScript document.

Note: Depending on the version of OS X/macOS the tell application "AppleScript Editor" line may be tell application "Script Editor".  You can still paste the example code, as is, into Script Editor and is will automatically remove the Apple portion from AppleScript to show as tell application "Script Editor".