Have you tried that? I can think of at least a couple of problems with that strategy. First, the AI may be inept, but I don't think it is that inept; it is too much to hope that it will never build a better unit or city walls. In the second case, it takes so long for units to heal in the field that you will be sitting outside the city forever.
The difference between building a warrior and building a "better" unit is like the difference between buying a minivan and buying a transport truck. Sure, the transport truck can carry more stuff, but if all you want to do is bring home the groceries, the transport truck is a waste of money, because the extra capacity is worthless.