You are right that the sentence is ungrammatical if you take the object of "want" to be "replace Windows" and the subject of "replace" to be "the Chinese government". But it is grammatical if you analyze it as an instance of the construction "X wants Y to Z", where Y is (semantically) the subject of the infinitive Z.
To a first approximation, relative clauses in English are formed by taking a sentence and moving some noun phrase to the front, while optionally adding "that" after the moved noun phrase.
E.g., "I saw the man" -> "the man that I saw _" (where _ marks the place where "the man" would have been if it was a regular sentence; called the gap or trace in linguistics.)
In this case the transformation is "the Chinese government wants the OS to replace Windows" -> "the OS that the Chinese government wants _ to replace Windows."
I agree it sounds somewhat awkward.