The data companies maintain that gathering the prescription data is good for public health--for instance, it might show that in a poor area with a high asthma rate too few inhalers have been prescribed.
With permission from air-traffic controllers who are monitoring any other aircraft in the area, it's not dangerous for pilots to divert from prescribed navigation paths.