The previous answer beautifully and accurately analyzed Wilde's texts in terms of his preferred writing styles and his predilection of genres. My answer will therefore try to answer the same question but from the point of view of Wilde's biography and how it blends in perfectly with specific works of his. Most of this information can be found in the superb biography written by Wilde's grandson, Merlin Holland, The Scarlet Marquess and the Irish Peacock, which I strongly recommend.
There is, indeed, a lot of personal value at stake in specific texts by Wilde, particularly when you look at :
The works produced six years prior to Wilde's conviction, aside from being his most popular works, are also works that feature the same conflicting issues that were going on in Wilde's life. This time period also coincides with the chaotic relationship between Wilde and Alfred Douglas. It is the latter's father, the Marquis of Queensberry, who would cause Wilde's conviction.
This being said, all of these works feature major salient themes that were also preoccupying Wilde:
- criticism of women
- fear of consequences
By 1895, Wilde had been blackmailed by Charles Parker and Alfred Wood (and others) over some sensually-suggestive letters that Wilde had sent to Lord Alfred Douglas, his off and on love interest.Under the Criminal Law Amendment Act, homosexual relations were considered illegal and punishable with a maximum sentence of two years of hard labor. That is exactly what Wilde was accused off eventually in 1895, and that was the sentence that he served.
In Dorian Gray and An Ideal Husband, and Lady Windermere the topic of blackmail is mentioned and talked about in ways that reflected Wilde's own knowledge about these things.
Excess and consequences
During this time it is argued that Wilde was also acting completely out of character by excessively consuming food and drink. By the time of his trial, he was overweight and many say that he was drinking uncontrollably. He was also spending excessively on his (male) love interests and on page boys.
All of this got him in a huge pickle with creditors (much like Ernest Worthing did in The Importance of being Earnest). He eventually lost everything he owned when his assets were seized by the government after his imprisonment.
The characters of Jack (Ernest), his friend Algernon Moncrief, Dorian Gray, Lord Henry Wotton, Lord Goring and Lord Darlington are all excessive individuals who are always chased by the consequences of their actions. All the 90-95 works also show Wilde's high preoccupation with the topic of "consequences".
Prior to his conviction, Wilde had been accused of corrupting young men. In The Picture of Dorian Gray, the character of Lord Henry is Wilde's mouthpiece, spreading Wilde's own ideas about the "modern hedonism" that corrupts Dorian into horrid acts that reflect in his painted image. Similarly, the dandies Moncrieff, Darlington and Wotton clearly are amoral therefore they have either already corrupted someone or will corrupt someone else.
Homoeroticism and criticism of women
Homoeroticism and criticism of women permeates each and every one of these 90-95 works. "The Portrait of Mr. W.H." talks about Shakespeare's love fixation with a young unknown male whose initials are "W.H."
Dorian Gray talks about the main character reading a "certain book" that influences him in a way that he starts to corrupt all young men who deal with him (Wilde was surreptitiously referring to Huyssman's A Rebour which is a homoerotic novel).
Women are consistently criticized or mocked. Lady Bracknell is a snob, Cecily and Gwendolen are conniving airheads, Mrs. Cheveley is a con artist, Sybil Vane is a weakling, Lady Wotton is "unkempt", and in general, men prefer to hang out close together without the annoying presence of their female counterparts.
Even in The Importance of Being Earnest the male characters do a lot of naughty deceiving before they finally fall in love with their respective female love interests.
Therefore, shortly before Wilde was arrested and accused, he had already put a lot of his own life onto his works, presumably because he was aware that something was going to happen eventually. Others say it is because he had a penchant for self-sabotage and wanted to give himself away for once and for all. Regardless the cause, it is certainly something to consider given the consistent way in which he presents these themes over and over.