It's part of the evaporative emission control system. As fuel is used from the tank air must enter or a vacuum would be created and flow would stop. The cap lets air in but it wont let fumes go out into the atmosphere. The computer sees that there is a leak in the system and cil comes on. Same as the newer gas can that you fill your generator with, they have a fancy cap so people dont lose or not reinstall the little push on cap. Pollution doesn't come from just the tailpipe.
They keep doing all sorts of things to find ways to minimize hydrocarbon release. Some small engines such as Stihl string trimmers have a mechanism in the control handle that wont let you shut off the ignition unless the throttle trigger is in the idle position. They dont want the engine spinning at a higher speed and slowing down with the ignition off spewing air fuel/hydrocarbons. The flaw in that design was that the cable and plastic parts were very touchy. If it wasn't routed and adjust very carefully it wouldn't engage and let you accelerate. I swore every time I worked on one and could only wonder how many people really hold the throttle open with the engine racing and want to shut the ignition off. Saving the world one weed eater at a time.