It would cause some practical difficulties if the corporation owned all its shares. For example, in the case of a Delaware corporation, shares owned by the corporation itself can’t vote, so it would not be possible to elect board members. Some jurisdictions might have legal limits on how much stock can be bought back as a percentage of the outstanding shares.
It’s not that unusual to have entities that essentially own themselves, in the sense that nobody is entitled to the profits and the board or managers elect their own successors. This is the case for foundations and trusts in many countries, usually with some kind of charitable purpose. Some of them even operate businesses. It might be possible for a company to take on some debt, buy out all its shareholders, and reorganize into a charity.
I think an easier path to have corporations which are not owned by anyone is to look at cross-holdings. Maybe one could theoretically get to a situation where a group of companies hold shares of each other and completely own themselves in the aggregate? Even if that may not be completely legal one can imagine that given the complexity of the situation one could accidentally end in a forbidden state.
The last share is worth whatever the person that holds it is willing to sell it for, right? A share of IBM is worth $136 right now because there are two parties willing to buy/sell a share of IBM at that price.
I realize this would never happen in a million years, but could a company exist that is owned by nobody?