As another answer has suggested, you can certainly make a day of having the car, some other potential points of interest being Manassas Battlefield Park, Great Falls Park, or a concert at Wolf Trap.
But while admission to the Udvar-Hazy Center itself is free, parking is $15, on top of rental fees, taxes, insurance, and fuel. If you take the Dulles Toll Road, that's another $3.50. The drive averages 30 to 45 minutes, depending on traffic, and you need to factor in time to pick up and drop off the car. If your only interest is the museum, therefore, you're paying a significant premium to save a couple of hours, one that not everyone may be willing to pay.
A cab wouldn't really be cheaper. Even Uber is currently estimating $40-$50 each way for a midday weekday ride from L'Enfant Plaza to the Udvar-Hazy Center. You might therefore consider a couple of single-transfer public transportation options:
- Silver Line Metro to Wiehle Reston-East, transfer to the Fairfax Connector bus 983. From L'Enfant Plaza, each way, this takes between 90 and 120 minutes and costs $4.85 total off-peak, $7.15 regular, with a SmarTrip card.
- Metrobus 5A to Herndon-Monroe, transfer to Fairfax Connector bus 983. From L'Enfant, each way, this takes about 90 minutes and costs $7 one-way with a SmarTrip card.
Without a SmarTrip, you will not receive any transfer discount, and will need to pay the full $1.75 for the Fairfax Connector 983 bus.
In between these options, you could take the train out to Wiehle-Reston, $3.60 off-peak or $5.90 regular, and grab a taxi or Uber/Lyft/etc there for $20-30.
Despite the proximity of the museum to the airport, there is no way to walk or bicycle between the two, so for those trying to visit while on a layover at Dulles, your options are similarly the 983 bus or a car, which runs $15-25. In some travel guides you may find reference to other shuttles or buses, but at this writing, they have all been discontinued except the FfC 983.