It's important service dogs pay attention to their handler when working, so focus is important.
If everyone were to pet a service dog, it would stop focusing on its job, which can turn out very badly for the person counting on it.
This is why service dog handlers are told to not let other people pet or treat the dog.