In the iconic tale, Senor Alonso Quijana may well have been Cervantes's alter ego, given the latter's own love of reading and adventure. Senor Quijana's obsession with the life of chivalry apparently mirrored that of Cervantes, who in his youth fought in the battle of Lepanto.
The Battle of Lepanto (1571) was a conflict of immense proportions between the Ottoman Empire and the Holy League, an alliance of Catholic powers. The Holy League was fronted by Spain, Portugal, Venice, and the Papal States. Notably, knights from Catholic orders also fought side by side with the Papal armies; they were the Knights of St. Lazarus, the Order of St. Stephen, and the Knights of Malta. Cervantes himself served under the leadership of Don John of Austria and relished his place next to the warrior monk orders.
Certainly, the stakes were high: a loss would have ceded Europe and the Mediterranean regions into Ottoman control. At the time, Cervantes was deathly ill on the Marquesa. At the approach of the enemy, however, he took up his arms without hesitation. In battle, Cervantes sustained grievous injuries, but he lived to talk about it. After the victorious battle against the Ottoman Empire, he continued to serve as a soldier. From Cervantes's perspective, he was engaged in just wars against an imperialistic Ottoman Empire, which he considered an existential threat to his people.
Cervantes was eventually captured by the Turks and imprisoned. He endured privation and torture during his incarceration, but his resilience, courage, and humanity remained intact. Cervantes was dauntless, even in prison: he tried to escape a few times, despite the difficulties before him. Although Cervantes didn't succeed, his tenacity was well noted by both his fellow prisoners and jailers.
Now, how does Cervantes's background influence his writing in Don Quixote? First, Cervantes's perspectives about valor are strangely identical to that of Don Quixote/Senor Quijada. To both writer and protagonist, a just war (to right the wrongs of the world) is a righteous service to king and God. In the story, Cervantes tells us that Quijada is a madman who believes that living the life of a knight errant would result in "eternal renown and fame."
Now, the question begs to be asked: if Cervantes relished the life of valor (and lived it), why would he satirize it in Don Quixote? What then, is the true purpose of storytelling? On the surface, it is to entertain. Perhaps it is also to inform. In Cervantes's case, it served at least two purposes. First, it was likely cathartic. Cervantes wrote Don Quixote in his declining years and had the opportunity to recall his experiences in past wars. It can be argued that the juxtaposition between reality and fiction within the context of the story served an important purpose for Cervantes himself. In his old age, Cervantes could compare his mature perspective with that of his youth.
He could question the efficacy of his beliefs and explore the ramifications of masculine identity without attracting undue attention from the Spanish authorities. Certainly, it was much easier to portray Don Quixote as a "madman." Such a one could explore uncomfortable topics about religion, warfare, masculine identity, and romance without incurring the harsh judgment of society and its leaders.
Second, Cervantes's unique brand of storytelling also allowed him to highlight (for himself and his readers) the discrepancy between convention and the human experience. Like many of his readers, Cervantes was raised with a certain set of values. These values influenced his perspectives about the world and cultures foreign to his experience.
Through Don Quixote's travels (and interactions with varied characters), Cervantes was able to emphasize our intrinsic hunger for truth, even in fiction. It is truth that will comfort us, especially when entrenched values collide with experiential reality.
He passed on, and saw they were also correcting another book, and when he asked its title they told him it was called, "The Second Part of the Ingenious Gentleman Don Quixote of La Mancha," by one of Tordesillas.
"I have heard of this book already," said Don Quixote, "and verily and on my conscience I thought it had been by this time burned to ashes as a meddlesome intruder; but its Martinmas will come to it as it does to every pig; for fictions have the more merit and charm about them the more nearly they approach the truth or what looks like it; and true stories, the truer they are the better they are."
In the last part of the novel, Don Quixote renounces the life of chivalry after an embarrassing defeat by the Knight of the White Moon. For Don Quixote, the reality of old age has finally reared its head. As for Cervantes, reality might have given him pause as he pondered the exploits of his youth. Catharsis, entertainment, truth, reality, inquiry: storytelling is about all of these things.
If you're interested in a great perspective on Cervantes's storytelling, try William Egginton's The Man Who Invented Fiction: How Cervantes Ushered in the Modern World. Below, I include a link to an interview with the Johns Hopkins professor and a review of his book by the Guardian.