In "Hamlet," Osric goes from being "hot" to "cold" to "sultry" in order to be agreeable. Why?
Osric is a very minor courtier who has an inflated idea of his own importance. In order to remain in a favorable position with the more important members of the court, Hamlet for instance, he affects different attitudes to suit what he feels is needful at the moment. His attitudes reflect his own ego-driven need to be included in the inner circle around Hamlet.
Answer taken down.
Osric is a foolish courtier. His career is based on the gossip and back-biting of court life, where to be unpopular means social exclusion and rejection by all. So Osric doesn't want to disagree with anyone because that may make people dislike him. And to disagree with someone as powerful as Prince Hamlet is extremely socially risky. Osric won't dare disagree with Hamlet, who could destroy his social reputation and popularity with one nasty joke or one social snub.
Hamlet knows this, so he bullies Osric to prove to Horatio how shallow and grovelling people are. He plays a game by repeatedly changing his mind about if the room is hot or cold and if Osric should wear his hat or not.
So, basically, Hamlet says "Gosh, it's hot in this room. Hats off"
So Osric says, "Yes, it is hot, isn't it?" and takes off his hat.
Then Hamlet says, "Oooh, but isn't it cold now? Hats on."
So Osric says, "Errr... Yes it is cold, how strange" and puts his hat on.
Then Hamlet says, "And yet, now, it is hot again, isn't it? Hats off."
And poor Osric, now very embarrassed and confused, desparately tries to keep his petty dignity without disagreeing with Hamlet.