Transistors function as current amplifiers or binary switches. With amplification, a small current controls a gate for a greater current. As switches, a 5-volt threshold (gate open) equals binary digit one, less than 5 volts (gate closed) equals binary zero.
A transistor has a base, a collector and an emitter. The base controls an electrical gate, the collector is a larger electrical supply current and the emitter is the output for that supply. Varying the electrical current from the base allows for regulation of the current flowing through the gate from the collector and outputted by the emitter. This is a transistor functioning for amplification.
When functioning as a binary switch, the identical control-gate/output process is used. The difference is that for the gate to be open (binary digit one), it cannot figuratively be ajar as within the amplification function, a 5-volt threshold is required. Anything less than 5 volts received from the base means the gate is closed (binary digit zero). This transistor function is fundamental to all digital processing.
Discoveries concerning crystals made at Bell Laboratories in the late 1940s made transistors possible. Nearly all non-metallic crystalline structures are insulators, not conductors. Some crystals, such as germanium and silicon, when forced to grow with certain impurities, have semi-conductive electrical properties. Wafers of these impure crystals sandwiched between conductive plates are transistors.