Arduino ESP8266 module communicate through Arduino IDE terminal
While it sounds like you have a serial voltage problem, even with that fixed you still have a conceptual problem with the serial links.

On a traditional Arduino like an Uno, pins 0 and 1 (which are the only hardware UART on the version of the ATmega in use) are already used for communication to the PC and serial monitor.

Thus you cannot use these to talk to the ESP8266, unless you effectively remove either the ATmega or the computer from the situation.  Some people do pull the ATmega out of its socket, or hold it in reset and thus "borrow" the Arduino's USB serial solution to talk directly from a PC to an ESP8266.  And in other cases someone working on a more completed project will forgo the computer serial connection, and use the ATmega's hardware UART to talk to the ESP8266.

But what you are trying to do, in talking to the ESP8266 through the ATmega, is not going to work when both conversations are trying to happen on the same pins.  Your code tries to use a software UART to talk to the ESP8266, which is potentially workable - but it will not accomplish your goal until you move the ESP8266 to different Arduino pins, in both the wiring and the sketch, in order to remove the present conflict over pins 0 and 1.