Why do we need to use transistors when building an
OR gate? Wouldn't we be able to achieve the same result without transistors at all, just by joining the two inputs and reading the output?
What you describe is called a wired OR connection. It is possible in some logic families, particularly ECL (emitter coupled logic), but not in the most common ones (TTL and CMOS).
In CMOS it isn't possible because when a CMOS output is low, it creates a very near short from the output pin through the chip to ground. And when it is high, it creates a very near short from VDD through the chip to the the output pin.
So if you tied two CMOS outputs together and one output high while the other output low, you'd have a very near short from VDD to ground, which would draw a large current and likely overheat one or the other of the two chips involved.
For TTL, there's a similar issue, but the "shorts" from the output pin to VDD or ground aren't quite as near short as they are in CMOS.
There's a variant output style, called open drain for CMOS or open collector for TTL, that allows wired AND connections rather than wired OR. These outputs are designed to only be able to sink current to ground, not to be able to produce any output current when they're nominally in the high state. These are normally used with an external pull-up resistor so that the output voltage will actually reach the "high" voltage level when required.
Note: Open collector or open drain can be used for wired OR if you use active-low logic (low voltage represents logic 1, high voltage represents logic 0).
If you just connect the wires, you'd have the (fairly likely) possibility of a 0 and a 1 together. Since a 0 is gnd, and a 1 is 5V (depending on the chips, but it's a standard), you'd have 5V and gnd connected together by wires. The term for that is a short circuit!
You could use diodes for a simple OR gate. Or even resistors. The problems occur when you connect this gate to other gates, other circuitry. You can build an AND gate from 2 diodes the other way round. But if you try connect a lot of them together you end up with one giant circuit that doesn't function as small separate parts, but as one big one. Connections that aren't in your simple gate plan, might crop up in real life, messing up what you want to happen.
A transistor lets you separate the input from the output. The output of a transistor can't feed backward and affect it's input. A relay would be another alternative, though slower. Since the switch can't affect the electromagnet.
Early logic was RTL or DTL, resistor-transistor logic, or diode-transistor logic. Resistors, at first, then later diodes, were used to form the gate, then a transistor acted to buffer the result so the next gate you used didn't feed back through this one to it's inputs.
Now, since transistors on chips are virtually free of charge, financially that is, we have the luxury of everything being properly buffered and separate. Usually that's what we want. TTL logic!
Consider what happens if one input is high and one is low, and you connect the two inputs. It depends on how you build your logic gates.
If your logic gates are designed so that a high is really pulled high and a low is really pulled low (CMOS) then this is a short circuit and something will blow up.
If your logic gates are designed so that a high is "weak" or high resistance (e.g. NMOS) then the output will be low, but also the other input (that is supposed to be high) will be forced to be low even though it's supposed to be high, and this will have a knock-on effect on other logic gates which use the same input.
There is an analog approach:
Combine any number of inputs (suppose either 0 or 5 volts) with resistors.
If the result voltage is 0, all are off.
If the result voltage is 5, then all are on.
In-between voltages indicate that some are on and some are off.
Example: If there are 4 inputs, 2.5 volts means 2 are on and 2 are off.
result == 0: nor gate
result == 5: and gate
result != 0: or gate
result != 5: nand gate
You don't need transistors for the inputs, just for the output to check the voltage and restore a 0 or 5 volt logical result.
This might be used for an analog neural network node with a non-linear output function that has a "soft" result that might not be entirely true or false.
Resistors used this way can slow down logic speed since capacitance following the resistors must be charged or discharged when inputs change. Also, use of transistors can greatly reduce power consumption. Resistors used this way can always consume power with a mix of input states. With transistors, power consumption can be roughly divided by the gain of the transistors.
With some logic elements (all car door swithches ighting up the same lamp) this is possible, but not for example with CMOS gates as they are built with P and N channel FET transistors so they need defined high and low voltage input to provide the output, the input cannot be left to float. Connecting CMOS outputs together would not work.