.
They were there for the feast of Tabernacles (Sukkot).
A celebration at the time Mesiach was to be born.
The census (not a tax) was done at that time because that was when everyone had to be in Jerusalem at that time (Romans weren’t totally stupid).
.
Seems like there’s a lot of disagreement here as to why they went. Taxes. Census. Ancestors. Which is it?