The roots of this word can be found in the Germanic languages. It is similar in Old English, Old Norse and Old German. In all cases, it is defined as wer (man) and geld (payment) (See Merriam Webster and DWDS (German Dictionary). Compare to modern Dutch: it still uses the term geld for payment.
This early medieval payment (or compensation) is made to avoid bloodfeud when a crime has been committed. The price is dependent on a victims’ rank in society. During Anglo-Saxon times this agreement was turned into a law (See Oxford Reference and Britannica).