Bootstrap Accordion with Dynamic content WordPress Archives Unique ID

the_ID() is for post IDs, so would only be relevant if you were adding an id attribute to individual posts.

For your purposes you can use anything you want, as long as it’s unique to the year, and since years themselves are unique, just use that: $year_current.

For example:

<div id="collapse-<?php echo $year_current; ?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-<?php echo $year_current; ?>">