A 301 passes ranking signals to the new URL and is best for permanent moves. A 302 is temporary and should be used only when the change is short-lived, or you risk losing link equity.