It's a linguistic vestige derived from English common law. It's used as a name to designate a political entity that is legitimized by the "common consent of the people", simply meaning that the authority of the governing body, in this case the state body, is derived from the public and not another source, such as royal inheritance or religious right. However since all States within the United States derive their governmental authority from the common consent of the people, there is no legal distinction between the words "Commonwealth" and "State" in regards to federal US law and any particular governmental uniqueness in these states (such as Virginia's independent cities) is not tied to the word "Commonwealth" and is instead derived directly from the constitution of those states.
So while Virginia is officially "The Commonwealth of Virginia" any and all legal structure within Virginia is based on it's constitution and any and all of those legal structures could be implemented by a state using the official title "State" as long as they are laid out within the officially adopted constitution of that state. Vermont is officially "The State of Vermont" but uses the word "commonwealth" a few times within it's constitution. In fact Massachusetts officially called itself "The State of Massachusetts Bay" until it was officially named the "Commonwealth of Massachusetts" by it's constitution. The Commonwealth of Pennsylvania also uses the word "State" a few times in it's constitution.
So in short, it's just a linguistic choice with no official legal distinction within the United States that is used by four states settled predominantly by English settlers and incorporated into the United States prior to 1800. Similar to how counties in Louisiana are called "parishes" and called "boroughs" in Alaska but any legal distinction between "county" and "parish" or "borough" is derived from the constitution of those states rather than from the words themselves. It is important to note that the word "Commonwealth" does have a legal definition and distinction for territories of the United States that are not states, but as I don't know the actual particulars of that legal definition I will refrain from describing it here.
Am I allowed to ask what the difference between a state and Commonwealth is?
I'd just like to add that Puerto Rico has a commonwealth status. What makes this different than the 'commonwealth' states?