I suspect the iPads wifi radio is put into a low power mode when no data is being sent. This may have an overhead that effects the ping time. iOS is not a 'raw performance OS' it is designed to conserve power where possible to improve the user experience.
When you are running Airplay the radio is sending & receiving data constantly, so the ping is faster as the radio is not deactivated & reactivated. The timing doesn't look too out of the ordinary to me, do you have a problem or are you just curious?
Try again when downloading/ streaming a video or something that keeps the wifi connection active, it may not be just Airplay that makes ping faster.
Also be aware that the router is another part of this conversation - it allocates resources to stream data to devices too, it may be faster when not having to intermittently reply to a device. It also manages it own power for the radio etc.