You don't necessarily get the best Wifi performance when your device is right next to or close to the router. This is due to the way that the Wifi signal bandwidth is interpreted when it is decoded.
For more information look up and read about QAM technology or Quadrature amplitude modulation (256 QAM, 64 QAM, etc..) . Wifi and especially 5Ghz Wifi actually utilizes the frequency reflections in your environment and the delays those reflections cause to increase Wifi bandwidth. If your device is too close to the router then those bandwidth enhancements due to reflection delays are not available.
Therefore an optimum distance from the router might actually be farther away from the router... often a medium range that would allow the Wifi to take advantage of those signal reflections and slight delays that actually improve bandwidth. If your device is too close to the router it could limit bandwidth. If your device is too far away and reaches maximum 5Ghz range then logically you lose signal quality and your bandwidth drops.
This would be different for lower power Bluetooth devices working in the generally crowded 2.4Ghz range because they would be more prone to signal interference and input devices (keyboard, mouse, etc.) usually don't require much bandwidth.