Relay vs. Transistor?
Relays offer complete isolation between the activating circuit and the load.
They can switch AC and DC, and be activated by AC or DC.
They can be very robust.
They also have the advantage that one can often see if the device is actuated, and one can even hear the actuation in many cases.
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.
Aside from all the correct properties that Leon mentions, relays also have a much lower internal resistance, in fact the switch of a relay looks quite a lot like a straight piece of wire.
Any other kind of solid state switch (bjt, scr, triac, igbt) will have some resistance and drop some voltage.
In many designs where switching is infrequent and the designer of the circuit doesn't know exactly what the user is going to want to switch, a relay is a nice choice as it will switch either ac or dc at a huge voltage and current range.
In a particular application you can almost always find a solid state component that will do the job cheaper than a relay, if you can do without all the robustness and versatility of a relay.