My Wi-Fi connection works on all Linux systems but none of the OS X distributions But even on Linux, the Wi-Fi works unsatisfactory dropping from time to time, and performs poorer than other devices at longer distances from the router. However I can still bear with it because with certain routers it works quite fine.

The OS X (Mavericks and Yosemite) on the other hand does not work at all with any router. Not even with the router at the Apple store. It simply doesn't connect. Even if it accidentally connects, it drops immediately after I try to load something.  I even tried to downgrade the driver and it didn't work either. It seems plausible to me that the problem lies in the driver itself, what can I do now?

The computer is a MacBook Air 11" Mid 2012.
The could be a couple of things going on, hardware or software. Let's eliminate software.

Go to /Library/Preferences and look for the ones that start with "com.apple.network" I have three of them. Delete them and reboot.

Now go back into your network preference pane. Any VPNs you set up will be gone and you should have the default list of all interfaces with network capability. Select the WiFi interface and configure that as you like.

What I am thinking is possible that you have a damaged preference file associated with networking (hopefully I didn't miss any preference files...). Doing this will give you a clean slate with network settings. 

If that doesn't do it, you may have a hardware issue, which means time for an Apple Genius appointment.