The end doesn't necessarily justify the means.

Literal

Purpose [topic-は] necessarily means [obj-を] not-justify.

必ずしも…ない ('not necessarily') is a fixed pattern — 必ずしも pairs with a negative predicate. 正当化する ('justify') is Sino-Japanese. A classic ethical maxim rendered in formal Japanese.