It is both... the indie gets paid for doing the safety/emissions inspection, and
in the course of that they fill out the out of state form and compare the vin number on the car to the one on the title. Good luck getting anyone to allow you to register the vehicle when it doesn't pass inspection. Until it does pass, it doesn't need registration as it can not be driven.
If that tag is the ONLY vin on the cab, yes, you need it, and you need it to match.
on modern vehicles, It is NOT the only vin on the body, there are numerous vins to verify the original identity of a chassis, cab, etc. The one on the dash is for show.
As far as removing and replacing them, legal or not, the vin tag isn't always attached to the vehicle itself... sometimes it is attached to the INTERIOR, LOL.
on Nissan Hardbody's it was attached to the dash plastic, so everytime you removed the dash overlay, you had just removed the vin, and when you replaced your rotted out dash with another, you had to swap the vin tags, or you'd fail your next inspection. It also mad it easy to replace a wrecked cab with an unwrecked one... jsut swap the dash pad.