means to an end

a means to an end
(a thing or action that is not interesting or important in itself but is a way of achieving something else) — средство для достижения цели

He doesn't particularly like the work but he sees it as a means to an end. (OALD)

Used when something you are doing (work) is not as important to you as what you hope to achieve by doing it (in this case, probably money). Whoever says this does not really enjoy their job in itself, it is a job they are just doing to earn some money.

.....People are more inclined to judge a means to an end as performed intentionally if they consider it as morally wrong than if they consider it as morally right.
..... Torture treats the victim as a means to an end and not an end in themselves. It treats the victim as a 'thing', not as a person with all the value that we associate with persons.
(BBC - Ethics: Why is torture wrong?)

Related
[Цель оправдывает средства]