This fell out of my toilet when I unscrewed the supply line. What is it?
This appears to do a few things. 


A backflow preventer.  Note the nub on the "top", that should actually go down.  Gravity and back pressure seats it on the inlet pipe to try to prevent tank water from backing up into the supply lines if there's a pressure loss or shutoff. 
A flow limiter.  Without it the toilet will flow faster, but will be more susceptible to water hammer.  The automatic valve opens and closes quicker than humans, and flowing water has inertia. Changes in inertia cause force.  That force can be destructive, which is what water hammer is. 
A shock absorber, if it's made of rubber.  This adds some compressibility to an incompressible medium, to help with water hammer effects, especially acting on that valve.