What is the purpose of a resistor?
There are other purposes that could be given, but a major purpose is to limit current to protect other components.
One example of using a resistor to protect other components:
Some light emitting diodes have resistors included in the package. Many do not have a resistor included. Not having any resistor in one of these would allow excessive current to flow thru the diode and blow it out. This link will explain how to choose the value of the resistor.
I hope this helps,