Does AirPlay Use Wi-Fi?
AirPlay goes through your local network, whether that's over Wi-Fi or wired ethernet or both.

To resolve your problems, you should probably clarify what you mean by "laggy".

Latency (Delay)

There is some latency (delay between when your Mac sends a signal and when it's displayed) inherent in the AirPlay technology, which can be compounded by latency in Wi-Fi. For something like playing a movie, a few hundred milliseconds of latency isn't a big deal, but it can be if you're trying to use it for something more interactive (e.g. a presentation, gaming, etc.).

The best way to reduce latency is to use wired instead of wireless networking, however given the limitations of AirPlay, it may not be sufficient for some intended uses (like gaming).

Other Issues

If you're experiencing poor quality or videos having to buffer, that's likely a problem with bandwidth, rather than latency. In this case, the issue could be your router — some simply have higher throughput than others, but it could also be an issue with the environment around you. The more Wi-Fi networks and other EM interference, the worse your signal will be. The construction of your house can also be a problem.

A better router can help in some, but not all situations — if the environment isn't conducive to good Wi-Fi (long range, lots of other networks, or thick walls), then a better router may not help. A wired network can help, and will certainly be more reliable.

There's no surefire way to know what your issue is without a bit of trial and error. If a wired network is possible, that will guarantee the best speed and reliability, but if you're looking for low latency over AirPlay, it may not be enough.