It is simply how Allah made things. He decided the number of months is 12. Allah says:
Indeed, the number of months with Allah is twelve [lunar] months in the register of Allah [from] the day He created the heavens and the earth; of these, four are sacred. That is the correct religion, so do not wrong yourselves during them. And fight against the disbelievers collectively as they fight against you collectively. And know that Allah is with the righteous [who fear Him]. (9:36)
Asking why is no different to asking why there are 7 skies rather than 10 or why is the Kaabah at Makkah rather than another city. It's simply God's choice.
A reason could be that the 12 lunar months are convenient because they line up with the solar year even if off by a few days in addition to the advantage of easy measurement using the moon. This may have helped people in the past to keep track of the seasons. They would know that summer starts only a few days later than it started last year.
However, then you could ask why is the solar year 365 days long rather than 300 days long. It's simply God's decision when He created the universe. There is no need to have a much deeper reason.
In addition, perhaps you do not realize this but the solar year gets its 12 months from the lunar year not vice versa. Originally, all humans followed the lunar year. Then, some people modified it and made a new calendar to follow the solar year exactly. Thus, the 12 months are a remnant from the originally followed lunar year.