The name of transistor comes from two terms: transfer and varistor which means a variable resistance in a circuit (usually collector-emitter) is controlled by the current in another circuit (usually the base-emitter circuit). The transistor was invented at the beginning of the last century (around 1930) as a solid state device to replace the triodes that were in use at that time in electronics. It is the main device used to amplify a signal in today circuits.
The advantages of the transistor were immense: it was many times smaller than the triodes that it replaced and it consumed a smaller electrical power. Thus the size of all electronic circuits was reduced by using transistors. The invention of transistor was preceded by the invention of the solid state diode, a device with two terminals (the anode and cathode) that also came to replace the very big diodes in use at that time. The first sold state diodes and transistors were made with punctiform contacts which means a local contact was made by melting a type of semiconductor (for example an N type semiconductor) on to the other semiconductor (a P type semiconductor). By melting diffusion between the two types of semiconductor took place and a PN junction was made. The difference between the diode and transistor is that the transistor has 3 terminals (Emitter, Base, Collector) being made by two diodes connected together having a common material for in the center (the Base which is very thin). Thus a transistor can be NPN or PNP depending on how the two diodes are connected together.
With time the fabrication of the diodes and transistors improved, being used diffusion or evaporation and deposition of different types of material (N or P). The characteristics of PN junctions improved thus and they could be used also for other purposes, for example to generate electricity when illuminated. The effect is called the photoelectric effect when a photon generates an electron and a hole which are separated by the internal field of the PN junction. Thus photo detectors were made starting from the same structure the diodes (or transistors) have. They are named photo diodes or photo transistors, and their conductivity is bigger under illumination.
Nowadays all these solid state devices (diodes, transistors, photo-detectors) are made together on to the same structure which is called an integrated circuit.