The main reason semiconductor materials are so useful is that the behavior of a semiconductor can be easily manipulated by the addition of impurities, known as doping. Semiconductor conductivity can be controlled by introduction of an electric or magnetic field, by exposure to light or heat, or by mechanical deformation of a doped mono-crystalline grid; thus, semiconductors can make excellent sensors. Current conduction in a semiconductor occurs via mobile or "free"electrons and holes. collectively known as charge carriers. Doping a semiconductor such as silicon with a small amount of impurity atoms, such as phosphorus or boron. greatly increases the number of free electrons or holes within the semiconductor.
It can be make in very small size and the electronics device are small in size that why the semiconductors are used in electronic devices.
The above explains HOW semi conductors work.
The reason for WHY they are used is, what's the alternative?
The only alternative is thermionic valves (tubes).
Tubes fell out of favour for many reasons.
They run hot
Made of glass and delicate,
Consume lots of power
Need high voltages.
Semi conductors are the opposite of all of these.