Radio basics: signal strength budget is
S = Tx power + Tx antenna gain - path loss + Rx antenna gain
which then has to be greater than receiver sensitivity (for link to work at all). And SINR is ratio between signal (S) and noise (which includes thermal noise, receiver noise figure, unrelated noise and interference), SINR defines achievable speeds, hence one wants SINR as high as possible. And one of means of getting SINR as high as possible is to have S high.
Also note that most realistic antennae don't have same gain in all directions, thus importance to direct antenna towards link peer (in case of PtP installation) ...
Now, sum "Tx power + Tx antenna gain" (a.k.a. EIRP) is limited by country regulations. However Rx antenna gain is not limited at all (neither is gain of Tx antenna). And since WiFi uses exactly same frequencies for both Tx and Rx, this means that Rx antenna gain on some device is same as Tx antenna gain on the that device. So while antenna gain doesn't help achieve higher radiated power
<*> (due to country limitations), it does help to make signal stronger on receiving side. It's not entirely black and white as high-gain antenna will amplify also interference (depending on antenna gain pattern and angle between link peer and interferers), but with some luck (or knowledge) high-gain antenna will improve link quality.
<*> This is not the whole story though. Realistic WiFi transmitters can't transmit at same maximum power for all different radio modes, most of them experience significant Tx power backoff for higher throughputs. Publicly available data for
hAP ax3 says that absolute maximum Tx power is 28dBm, but maximum Tx power for highest speeds (MCS11) is only 20dBm (numbers are for 5GHz radio). Calculation is as follows: EIRP limit for certain country and certain channel might be 30dBm and antenna gain is 5.5dBi. Meaning that max Tx power is limited to 24.5dBm. So for lower speeds, it's EIRP which limits Tx power (device max Tx power is much higher than that ... for hAP ax2 it's not so much, it's absolute max Tx power is mere 24dBm), but for higher speeds, it's device radio output (20dBm) which restricts transmitted power. So for hAP ax3, actual EIRP will range between 30dBm for low speeds (country limitation) and 25.5dBm for highest speeds (transmitter limit). If antenna gain was mediocre (e.g. 3dBi which was usual figure for previous generations of APs), actual EIRP would be between 30dBm and 23dBm (with EIRP curve dropping below 30dBm at much lower rates than it does with high gain antennae).
Also consider Rx sensitivity, which also usually drops with higher rates (-96dBm for lowest speeds v.s. -67dBm for highest rates, again for hAP ax3 and 5GHz band). If you add 0dBi (antenna with no gain) or even negative number (if using shitty antenna, unfit for certain frequency band ... happens a lot for WWAN due to wiiide frequency range used, i.e. from 600MHz up to 5GHz, which is realy hard on antennae), meaning that receiver is pretty deaf for higher rates (and then higher power of transmitter really helps). Using good Rx antennae (which are also Tx antennae) helps with reception a lot.
Also important: often mobile clients (e.g. phones, etc) aren't capable of high Tx powers, could be they can only work up to 20dBm (or even lower). As the same equation applies also for uplink, it's obvious that high gain AP antennae help very much in the uplink direction.
Ah, and BTW, antenna gain is physical property of particular antenna design ... it's not something that can be adjusted by software. ROS only takes information about it into account when calculating Tx power to be used to adhere to EIRP country regulations at all times.