Yes, it was necessary in order for God to fulfill his promise of Ps 110:4.
Except for that part where Paul states he is not under the law (1Co 9:20),
and he was not talking about the law regarding the priesthood.
Okay then, let's examine the context--7:11-22.
1) vv. 11-12 - The Mosaic law was based on the priesthood, the priesthood was not based on the law:
". . .the Levitical priesthood, for on the basis of (under) it the the law was given to the people."
(Heb 7:11)
So no Levitical priesthood meant no basis for the entire Mosaic law,
because the priesthood was necessary to administer the Mosaic law.
So vv. 11-12 are not talking about the law regarding the priesthood.
2) vv. 18-19 - ". . .(for the law made nothing perfect), and a better hope (new covenant of grace)
is introduced, by which we draw near to God." (Heb 7:19)
The law that was set aside is contrasted to the new covenant (better hope),
showing that the law under discussion is the one on which the old covenant
was based i.e., the whole Mosaic law.
The law of the priesthood does not fit the contrast,
in addition to Paul's clear statement that he is not under the law.
3) And the conclusion of the matter is:
v. 22 - "Jesus has become the guarantor of a better covenant."
Heb 7:11-22 is about the new covenant of the new eternal High Priest,
being a better hope than the old covenant of the Mosaic law.
And that is the new covenant law of Christ (Mt 22:37-39; Gal 5:6),
which Paul is under (1Co 9:21) and
which replaces the old covenant law of Moses because
it was weak and useless to obtain righteousness (Heb 7:18-19).
Heb 7:11-22 is not about the law regarding the priesthood,
it's about the entire Mosaic law.