What is this part and does it have to do with my my z-position is messed up? I recently bought my first 3d printer, a monoprice maker select v2.

After a couple of print jobs, this piece fell out.



I have no idea where it came from.

But afterwards, I notice that my Z-positioning is all screwed up.

When I select "Home All" to reset all positions to do bed leveling, the extruder tries to push down pass the build-platform, puncturing a hole into the plastic bed cover.
There was a lot of clicking from the motor so I immediately turned it off.

I turned it back on and then tried to move the z-position back up. But it moves only about an inch up before the motor starts clicking again. 

I was reading some other posts about a "Z-axis limiter switch". Could that be what the little metal fork-like piece is? 
Where does it go and how do I put it back?
And how do I reset my z-position?

Any help appreciated.
Limiter Switch/Endstop
That is the lever that is meant to trigger your Z-Endstop. The variant used in your case is on the cheaper end and is meant to look similar to this QIAOH KN12-1 limit switch:

You will either exchange the endstop as a whole, somehow reattach the/a lever or change the physical position of the endstop so that the moving X-axis is triggering it (again).
Replacement &amp; Wiring advice
Pretty much any switch that can have both an NC/NO (normally closed/normally open) state will function in its state, but it is usually a good idea to have all safety switches (like limit switches) be NC types and have the firmware detect the loss of signal as a safety feature. In case of a broken cable, this will automatically force the machine to halt, instead of keeping the machine moving despite having reached the maximum position.
Normally Open/Closed
It is even possible to wire up a number of redundant switches into one circuit. For NC setup, all the switches need to go in series, so that any switch getting toggled cuts the signal at that point. On the other hand, if only NO switches are used, they have to be wired in parallel: the signal passes when any number of switches is closed.
NO switches, because they are parallel, do cost us in the security department, as a broken lead does not halt the machine's use, but they are easier to troubleshoot as a broken component only takes out its specific arm of the parallel circuit. On the other hand, the NC-series does give us the broken lead security, but a single broken component that stays switched to open disables the whole series and identifying the broken component can take more time.
NOT-Gates
As you can imagine, some clever electronics allow us to use us to turn an NO into an NC and vice versa. This clever piece is a NOT-gate, sometimes also called inverter. They take a logic signal and a supply voltage lead, and only allow the supply voltage to pass into their output if there is no signal in their input side. So, they allow using a NO switch as an NC switch or vice versa. In any case, the NOT-gate needs to be on the output side the switch(es) it shall invert as it only inverts the signal that happens before it in the circuit.
With this clever piece, one can use a combination of NO and NC switches, if one so desires: The NO and NC parts are to be wired separately in groups (the NC group in series, the NO group(s) in parallel). To combine the two signals, there are two ways: Either run the NO output through the NOT-gate into the NC circuit's input, putting it into the series (and making it technically function as a single NC-element), or put the NC group output signal into the NOT-gate and put both groups in parallel. In either case, the NOT-gate 'flips' the function of the switches to behave as if they were the other type: from NC to NO and vice versa.