You are all missing the problem.
did you terminate all open CMOS inputs used with switches with a resistor? 1~100k to Gnd, close to chip.
Your big problem is all Wires must be twisted pairs with ground both on inputs and outputs more than 1" and two good decoupling caps on top or beside the chip with the proper voltage on supply. The relay coil will kick back large currents causing crosstalk, so these need to be twisted pair too. AWG30 magnet wire is sufficient with 12 turns per inch or so.
So 4 problems. Simply fixes.
Drop 5V to 4.3 with a diode for 74AC chip,
add caps to Vcc, of 4.3V
add diode to shunt reverse coil EMF, as mentioned already.
Use twisted pair for long wires.
Add pull-down R 's if you forgot to 4.3V, as I just did...to all CMOS inputs to SPST switches to 4.3V and NOT 5V!!!
Rb must guarantee Ic/Ib>=10 so for 30mA coil , you were a bit low with only 2.5V or 2.5-0.7= 1.6 mA or about half of what you needed. Ib on each transistor must be >=3mA , pref <5mA.
Spec'scct I saw omitted the reverse diode which protects the 2N2222 from premature failure due to secondary breakdown.
Hy Tony,
I cant see that anyone is missing the problem. Perhaps you have not read all the posts in this thread.
As previously stated, the problem is that the original circuit oscillated/induced hash for the reasons already stated. We have already described fixes, which I judged not to be to be worth the effort. Instead my circuit fixes the problem by eliminating the source, rather than sticking plasters all over the place. It is also simpler, smaller, easier to build, more expansible, and less prone to oscillations/pick up, never mind how many additional measures are taken with the original gate.
The relay is only 30ma and the supply line is only 5V so an up swing catching diode is not necessary for a 2N2222 which has the following characteristics.
(1) Vceo: 40V
(2) Vcb0: 75V
(3) Icm= 600mA
(4) Ptot= 625W
It is conceivable that a down swing could reverse bias the transistor EB junction via the forward biased CB junction but the resistance in the base circuit does limit the current and would tend to absorb the energy in the relay coil . Even though I have not seem any significant up and down swings from this type of relay, for belt and braces, it may be wise to fit a couple of 1N400x diodes, one from the collector to the 5V line and one from the collector to the 0V line.
Your statement that the transistor has to have Ic/Ib =10 is not an absolute truth as I have said before. It is a specification condition used in data sheets to measure deep saturation. I have used Ic/Ib= 50 which is more than adequate, especially as that is calculated with an input voltage of 2.5V, rather than the full 5V. The objective in not necessarily to put the transistor into deep saturation, but to provide sufficient voltage and current to operate the relay. The must-operate voltage for the relay is only 4V. The 2N2222 has an hFE of around 200 with a VCE of 1V, so it will have an extremely low VCE, more than low enough to operate the relay. Besides which, it would have been a trivial exercise to push more base current into the 2N2222, but it is simply not necessary or desirable.
Finally, the proof of the pudding is that the circuit works, as stated by the OP.
spec
Data Sheet 2N2222
https://www.onsemi.com/pub_link/Collateral/P2N2222A-D.PDF
Data Sheet Omeron GSV-1-DC5 Relay
https://www.omron.com/ecb/products/pdf/en-g5v_1.pdff