Rather basic, I'm afraid, but when would you use a relay, and when would you use a transistor?  In a relay the contacts wear out, so why are relays used at all?
Relays are on-off devices. Transistors can have their voltage drop varied.

Relays are far slower than transistors; typically 50ms to switch, and probably more. Some types of transistors can switch in picoseconds (almost 10 orders of magnitude faster.)

Relays are isolated. Transistors can be (e.g. SSR), but are often not.

Relays are electromagnetic and bring problems with them - for example, try building a relay computer with many relays. You will find that relays will interfere with each other in some cases. Transistors are not very EM sensitive. They do not emit much electromagnetic interference.

Relays consume a lot of current in the "on" state, most transistors do not.
