Falcon 9 does not have enough capacity; the JWST is too heavy for it to launch all the way to L2. So F9 is out.
Falcon Heavy does have enough capacity, but:
1. It was not really available for bookings when the JWST mission was planned and
2. even if NASA could choose again today, Ariane 5 has a track record of 106 successes out of 111 launches (107 out of 112 now I guess) and Falcon Heavy is still relatively untested with only 3 launches (all of which were successful, but still only 3). For something super critical you might want to go with old but dependable technology over the newest hotness.