First, we highly recommend that you download the AirServer Connect app on your iOS device(s). This is a free app, available in the App Store, that will help your iOS devices discover and connect to your computer. You would open AirServer on your computer, open AirServer settings, click the QR code, and then use the AirServer Connect app on your iOS device to scan the QR code. Once a connection is made, simply turn mirroring on.
If you are using a non-Apple based router, visit the router manufacturers website, download and install the latest firmware. In most cases this resolves the connection dropping and lag related issues.
Try disabling the Auto Lock feature on your iOS device. Go into the settings app, tap the General tab, and find Auto-Lock. Set this to Never. If Auto-Lock is enabled, your iOS device can go to sleep and cut the connection after some time.
Another cause of this might be that your connection cannot handle the bandwidth. If your computer is also connected to the network over WiFi, try switching it over to wired connection.
If you are using non-Apple bluetooth devices, they could be interfering with the Wireless connection and causing lags. Try turning off all bluetooth devices that aren't from Apple.
For best results, re-arrange your networking equipment such that you at least receive 2 bars of WiFi signal.
If none of this resolves the issue, and your computer is equipped with WiFi, try setting up an ad-hoc connection between your computer and your iOS device to rule out any router related issues.