"contentedly" is basically another way of saying "happily"
This word modifies the verb "lives". It describes in more detail how the animal lives, rather than just simply saying "the elephant lives"
elephant = noun
endangered = adjective, since it describes the noun (elephant)