Why does an inverter circuit (NOT gate) need both a transistor and a complmentary transistor?
Absence of voltage is not the same as zero volts in real circuits.

If you just have the top transistor, then you have a circuit that can source current but not sink it. If you need it to drive a PNP transistor - such as another copy of the same circuit - then it won't work properly.

You could have a PNP transistor and a pulldown (in1/out1), or an NPN transistor and a pullup (in2/out2):







simulate this circuit &ndash; Schematic created using CircuitLab

The latter is known as "open collector" and is quite common in TTL circuits.

Of course, having the resistor there consumes a certain amount of power when the transsitor is on, so using two transistors avoids that.

It's even more important with MOSFETs, as "no voltage connected" often turns into "voltage induced by nearby radio signals" or "whatever voltage was last connected to the gate capacitance".