The F-35 isn't hilariously unreliable, that's Russian propaganda that they laundered through known lying fuckwad Pierre Sprey.
As for why we went with it... Because the CAF wanted it. Putting aside all other considerations, it is the better aircraft. And at the time the notion of the US completely stabbing us in the back didn't seem like a realistic possibility.
We absolutely should switch to buying the Gripen now, what Saab are offering is amazing and there are very good reasons to get away from the US. But let's not start pretending that all of that was true when we signed the deal. At the time, the arguments against the F-35 were mostly fabricated bullshit that Russia fed us because they didn't want all of NATO to be armed with a weapon system they have no effective way to counter.