Which of the following methods should I use to actuate a solenoid from a microcontroller?
Why use a transistor to drive a relay?

Because the transistor can handle a lot more current than a digital output of a microcontroller.  A relay might need 60 mA at 5 V, whereas a microcontroller output might only be able to deliver 20 mA.  The transistor provides current gain.  It can be controlled with only a few mA, and can then switch considerably more than that.

Driving a solenoid

Your ultimate goal is to drive a solenoid from a digital logic signal.  First driving a relay, then having the relay drive the solenoid is unnecessary complication.  With the right circuit, the solenoid can be driven using transistors as amplifying devices instead of relays.  This is desirable because transistors are smaller, cheaper, more reliable, and the result will be more efficient.

Consider that the coil of a relay is a solenoid.  You already know how to drive one.  The only difference might be that the solenoid you really want to drive requires more current than the coil of a relay to switch the solenoid.

However, that's just a matter of choosing the right active part to drive the solenoid.  For example, here is a circuit that can drive a 24 V solenoid from a 0-5 V digital logic signal:



This transistor can support several amps, and has a maximum on resistance of only 29 m&Omega; with 4.5 V gate drive.  At 2 A, for example, it will dissipate no more than 116 mW.  Unless your solenoids need more than 2 A or so, this will do fine.