What is this pipe called, and how does it work?
A capped opening in a sewer line is called a clean-out, usually they are a 4" long bend wye with a cap on one branch so you can pull the cover and run a snake down the whole length of the main sewer line.

In this case, a 2" pipe would be a good size to run a snake down to clear any clogs downstream from the toilet. I'd guess that somebody didn't allow enough drop in the sewer line and added the pipe to allow shoving the solids out of a long, level area.

Sewer Auger (Snake) or a Water Bladder Clog Buster just in case you ever have to use it.

No, it's not a vent.