Middle English apecher, from the French empeechier, to hinder, stop, impede, capture. That was in turn derived from Latin impedicare, to fetter or capture.
In law, "to accuse, bring charges against" from the late 14th century, particularly of the King or Parliament. The sense of "to accuse a public officer of misconduct" was in use by the 1560s. The switch of sense was possibly due to a confusion of mediaeval Latin, from impedicare to impetere, "attack, accuse"