ESP8266 not working to drive relay
One problem that I can see with your circuit is that the 2N2222 transistor may not have sufficient current gain to turn the relay on (and keep it on).
The relay may need anywhere from 60 to 100mA, the transistor gain is guaranteed around 50 at around 100mA AND (this is VERY important) 1.0V across the collector-emitter junction.
 This means that you might have only 4V available to the relay, and some 5V relays need at least 4.5V to turn on.
 It is not clear from your question whether by the circuit "not working" you mean the relay or the IC?
 I would suggest using a low voltage MOSFET (even a regular one should work since it needs to drive a small current) instead of a bipolar transistor like 2N2222, as that would solve both problems at once: it would not load the IC output and it would have almost no voltage drop (giving the relay the full 5V for its operation).
 Check the voltage on the output pin when the transistor is connected, and check the voltage on the collector pin when the transistor is on, and let us know what you got!  

P.S.: Some of my values above may be somewhat incorrect, but the issues mentioned are present.