Unfortunately since its initial release, A.I. has been plagued with discussions about which filmmaker, Kubrick or Spielberg, was responsible for which elements of the story, with critics and audiences alike refusing to accept that A.I. cannot be trivially classified as a Steven Spielberg film or a Stanley Kubrick film - an indication of how unhealthy we're all subconsciously tied to the auteur theory.
As you've already pointed out, A.I., for the most part, operates at an extremely ambivalent tone - a result of Kubrick's chilly bleakness squaring off against Spielberg's warm-hearted optimism. It deliberately keeps its humanity at a distance so that audiences will try to define it. The ending to A.I. is, in my opinion. the single greatest piece of filmmaking of Mr. Spielberg's career.
The problem with the ending is that people always seem to believe the supermecha's story about creating Monica for a single day. As you've shrewdly noticed, the Monica they create is nothing like the one we saw from before; she's a fake designed solely to unconditionally love David, just as David was once created to unconditionally love Monica. But in this moment, both David & the audience assumed that their love was "real", which is why everyone complained about this being a happy ending.
Is this our understanding of love? Programmed obsession? In fact the ending is visibly ironic. Interestingly, Spielberg directs the entire sequence as a freudian wet dream of a boy expressing his romantic yearnings towards his mother. We see David make Monica some coffee, we see them play hide and seek together, we see Monica give David a haircut (If you recall in the 1st Act, it's David who cuts Monica's hair), we see David tuck Monica in bed (and not the other way around), we see them celebrate David's birthday (as opposed to Martin's) and here we see Monica looking at David's paintings whereas in the 1st act, it's David who's observing Monica's family photos. All the events are repeated, except now the roles have interchanged. David is the one who's desires are being fulfilled. He's playing the role of the human this time. The supermeccha's are doing precisely what Prof. Hobby was doing before, but in a subtler form. They give David what he wants while they observe him to see what happens. He's the last connection with humans, they study him.
Fake Monica tells David she loves him, he cries, then contentedly crawls into bed next to her dead body and dies next to his lover's corpse. Now that in itself is a tragic ending but it gets darker the more you think about it. Jonathan Rosenbaum nailed it in his review, saying the ending sparks a feeling "too terrible to name". Love is an illusion. Human's are as biologically programmed to love as David is. It's a byproduct of our evolution and importantly it's an utterly solitary fixation. David doesn't even realise that his mother has been replaced. None of what happens at the end is "real", the Monica is just an empty vessel, a product of David's imagination, but David believes it, and is happy to "go to that place where dreams are born". Spielberg and Kubrick are indicating how self-delusion can result in wish fulfilment.
Everyone complaining that David naively took the Pinocchio story too literally has completely missed the allegory Spielberg has presented here. David's quest to find the Blue Fairy is symbolic of man's eternal search for the god he created with the Pinocchio fable being his Bible (or Koran or whatever religious text you believe in). In a moment of sheer beauty at the bottom of the ocean, we see the blue fairy's face dissolve into David's suggesting that she exists within him. A.I. is filled with religious symbolism ( including its circular narrative , inspired by the biblical parable about the story of Eden ). The ending (when David finally encounters the Blue Fairy) is Spielberg's version of heaven, when man finally encounters god, face-to-face. Only difference is it's a complete illusion here, a Freudian wet dream, with all sorts of extremely creepy sexual undertones which can only be attributed to Kubrick, given he's explored similar themes in the Shining.
When fake Monica dies, A.I. addresses what modern philosophers (such as Camus) would label as the only important question in life: the genesis and exodus of humanity itself: suicide. To be or not to be? David self-terminates and accepts death because he understands that he no longer has a purpose in the world - something the supermeccha's have yet to accept. Now is when you can call him "real", a mortal. Recognising death is what makes us alive. As Heidegger pointed out, this results in a hugely important and seemingly paradoxical thought: freedom is not the absence of necessity, in the form of death. On the contrary, freedom consists in the affirmation of the necessity of one's mortality. It is only in being-towards-death that one can become the person who one truly is. Concealed in the idea of death as the possibility of impossibility is the acceptance on one's mortal limitation as the basis for an affirmation of one's life.
In fact even Joe starts to tread down this path with his chilling final line "I am I was", a reference to Descartes' quote "I think, therefore I am". Even the heuristic Joe has taken Descartes’ logical next step in evolutionary progression, being self-aware of one's mortality. He’s participated in history and knows it. Later, when David plunges into the Sargasso, calling softly for his mother, his image becomes a reflected tear in the eye of Joe (who is, we might suddenly realise in his grief for David, a Joseph?): Spielberg gifts him with the feeling he can’t express.
Audiences took the mecha story as "truth", and so left disappointed, faulting Spielberg for putting a "happy ending" onto the film, when he did the exact opposite. He simply shot it from David's emotional p.o.v., in a sequence that is cousin to the ending of 2001: A Space Odyssey (1968). But there is another level of metaphor in A.I. that few sci-fi films have dared to touch. The central question of Collodi's Pinocchio fable has always been "What does it mean to be human?" A.I. finds dark and sobering answers.
Regardless of your reservations about his past work, Spielberg makes an awful lot of other film-makers look timid and negligible by comparison and that's something that's not easy to do. "At the very end, he's reaffirming the bed room sequence from 2001: A Space Odyssey and in doing so he locates the unspoken moral of all fairy tales. To be real is to be mortal; to be human is to love, to dream, and to perish."