AppleScript issues with Terminal commands
You are having problems with the quoting of commands in a command.

An easy way out is to put the command ina shellscript e.g. name the script ~/bin/install_homebrew and after creating it make it executable  

Script is 

#!/bin/bash
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)


the call the script from the terminal or from Applescript

tell application "Terminal"
    do script exec "~/bin/install_homebrew "
end tell