I made a simple circuit with a 9 volt battery, a dc motor, and a potentiometer. The positive of the battery is connected to one side of the potentiometer and the negative to the other. One side of the motor is connected to the negative battery side and the other side is connected to the middle pin of the potentiometer. When I turn it, the motor is either off or on. How come the speed doesn't change since I am varying the voltage? Why do I have to use a transistor in this case with an Arduino?
What you're seeing is probably a combination of two things: the current capacity of the 9V battery and the resistance of the potentiometer.
Your typical household 9V batteries are notorious for their very high internal resistance. If you're trying to source more than just a few 10's of mA, the voltage across the battery's terminals will begin to drop considerably. You didn't say anything about what kind of motor you have, but I would guess there's a strong chance the battery is having a hard time turning the motor at all, even with low external resistance.
Now for the potentiometer. You have the right idea using the pot as a variable resistor. For the simple experiment you're doing, there's no need to connect the other side of the potentiometer to ground. That's just needlessly wasting current out of the battery. This should be all you need:
simulate this circuit – Schematic created using CircuitLab
The reason it's not working for you is because the 10k value you picked is simply too big. Turning the pot even just a little bit will quickly introduce several hundred Ohms, which will drop almost all of the voltage across the pot resistance before it gets to the motor.
In order to figure out how big the potentiometer should be, experiment with static resistors in series with the motor first. Find the largest resistance that still allows the motor to turn slightly. You'll probably find the value is very low: a few 10's of Ohms or in the low 100's. If you then use a potentiometer in that range, your experiment will work.
You CAN vary the speed with a simple potentiometer. BUT you must use a pot of a resistance value appropriate for the circuit. In your example you use a power source with a low impedance, and your motor has a low impedance. But you are using a pot with such a high impedance that it won't let enough current through to turn the motor unless it is essentially at the top of its range.
Note, however, that if you DO use an appropriately low impedance pot, you will be burning up most of your power in the pot which will not only kill your battery quickly, but may even be dangerous to the pot, causing overheating and premature failure.
Furthermore, controlling the speed of something like a DC motor by varying the voltage (even in an efficient way) is a poor technique. It limits the motor to low torque at lower speeds because of limited power. That is why it is more common to see PWM (Pulse-Width Modulation) used to control motors (and lights/LEDs as well).
PWM allows motors to have more torque at low speeds. And it is also much more efficient (less wasteful of power) because the controlling element (typically a transistor) is either full-on, or full-off. So very little of the power is wasted as heat in the control element. This is the common method used with microcontrollers like Arduino, et.al.
The other answers haven't mentioned a big part of the problem, which is that the device you are controlling is a motor.
The current capacity of the battery may also be a problem but I'll assume that the motor is small and low-power enough that doesn't matter (runs well for a decent time connected straight to battery).
Now if you connect a very high resistance load like a voltmeter, you'll find the output is 9V whatever the resistance of the variable resistor : but if you connect the other end to ground (potentiometer connection) the voltage will vary smoothly. So, by varying the resistance, you are controlling the available current.
But a motor acts as a very low resistance when it's stopped, and appears like a high resistance when it's running. (Its actual resistance doesn't change but when running freely, it generates "back EMF" which opposes most of the driving voltage.)
So to get it to start at all, you need to supply several times its operating current. That means turning the potentiometer almost fully up, so when it does start, it immediately runs up to almost full speed.
To control a motor's speed, you want to control the applied voltage, not current. One way is to use the potentiometer to control the base voltage of a power transistor, wired as an "emitter follower" (that is, a high current source at a specific voltage). The transistor dissipates power and gets warm so people generally prefer the "pwm" scheme in Richard's answer.