Deuteronomy 21:9

9 You must purge from yourselves the guilt of shedding innocent blood, for you will be doing what is right in the Lord's sight.

Deuteronomy 21:9 Meaning and Commentary

Deuteronomy 21:9

So shalt thou put away the guilt of innocent blood from among
you
Which otherwise, the person not being found out, and brought to just punishment for it, would devolve upon the whole. Aben Ezra interprets it the punishment of innocent blood, which, by the above method being taken, would not be inflicted on them:

when thou shalt do that which is right in the sight of the Lord;
as it was to observe this law concerning the beheading of the heifer, with all the rites and ceremonies belonging to it here enjoined; as well as every other command, statute, and ordinance of the Lord, which are all right to be done, ( Psalms 19:8 ) .

Deuteronomy 21:9 In-Context

7 They will declare, 'Our hands did not shed this blood; our eyes did not see [it].
8 Lord, forgive Your people Israel You redeemed, and do not hold the shedding of innocent blood against them.' Then they will be absolved of responsibility for bloodshed.
9 You must purge from yourselves the guilt of shedding innocent blood, for you will be doing what is right in the Lord's sight.
10 "When you go to war against your enemies and the Lord your God hands them over to you and you take some of them prisoner, and
11 if you see a beautiful woman among the captives, desire her, and want to take her as your wife,
Holman Christian Standard Bible ® Copyright © 2003, 2002, 2000, 1999 by Holman Bible Publishers.  Used by permission.  All rights reserved.