If there are parked cars, you have to move into the lane or risk getting doored. Near intersections, you have to move into the lane or people will cut you off and turn right in front of you when you're going straight. If the road has no shoulder, you have to move into the lane to dissuade people from running you off the road by trying to pass with insufficient space (and to give yourself some margin in case someone tries). The same holds if the shoulder is full of debris. If you're descending a hill, you have to move into the lane so you can maneuver around turns.
Any safe cyclist will spend some time taking a lane of traffic.