One-dimensional swimmers in viscous fluids: dynamics, controllability, and existence of optimal controls