How Does TeamViewer Fix My Computer's Network Lag?

I have a laptop with an annoying network lag issue.  Pings are slow, with occasional dropped packets.  An example series of pings to google.com is below.

Reply from **Please do not post IP addresses**: bytes=32 time=330ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=2096ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=919ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=337ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=522ms TTL=53
Request timed out.
Reply from **Please do not post IP addresses**: bytes=32 time=1418ms TTL=53

However, if I enable TeamViewer and connect to any external computer; then the lag on my local laptop is completely resolved, with consistent ~56ms pings like the series below.  Note that I am not doing anything on the remote computer.  Instead TeamViewer is enabled in the background and I am only using the local computer, with the same Wifi network.

Reply from **Please do not post IP addresses**: bytes=32 time=56ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=56ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=56ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=56ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=57ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=56ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=56ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=56ms TTL=53
Reply from **Please do not post IP addresses**: bytes=32 time=56ms TTL=53

If I disable TeamViewer, then the pings immediately get slower and gradually increase to up to ~2 seconds with dropped packets over the next few minutes.   I'm guessing TeamViewer does something to my laptop and/or network to minimize lag?   I'd like to learn what that something is, so I can have lag free operation when I'm not running teamViewer in the background. 

Does anyone have ideas?  The laptop with the lag is a ~4 month old HP running Windows 10.   It's had network lag since day 1.   Other computers on the same Wifi network do not have lag.